Subsonic ActiveRecord fails on compilation due to GUID
I have just downloaded subsonic 3, but when I try to compile my website, I get some errors. The errors all seem to relate to cases where I use GUIDs as foreign key. One example is the code below, where CreatedBy is a foreign key to my membership table. I have highlighted the affected lines.
public void Add(IDataProvider provider){
**if(String.IsNullO开发者_如何学CrEmpty(this.CreatedBy))
this.CreatedBy=Environment.UserName;**
var key=KeyValue();
if(key==null){
var newKey=_repo.Add(this,provider);
this.SetKeyValue(newKey);
}else{
_repo.Add(this,provider);
}
SetIsNew(false);
OnSaved();
}
public void Add(string username){
**this.CreatedBy=username;**
Add();
}
public void Add(string username, IDataProvider provider){
**this.CreatedBy=username;**
Add(provider);
}
user514090 - wouldn't you have to create the guid from the string 1st in your model along the lines of:
this.CreatedBy = new Guid(username);
I know i had issues with guids before and tackled it in a way 'similar' to this.
精彩评论