110,536
社区成员
发帖
与我相关
我的任务
分享
public class Test
{
[Key]
public string ID { get; set; }
public string Title { get; set; }
public virtual ICollection<Test1> Test1List { get; set; }
public virtual ICollection<Test2> Test2List { get; set; }
}
public class Test1
{
[Key]
public string ID { get; set; }
public string Title { get; set; }
public virtual Test Parent { get; set; }
}
public class Test2
{
[Key]
public string ID { get; set; }
public string Title { get; set; }
public virtual Test Parent { get; set; }
}
public bool Eidt(Testl model)
{
try
{
using (var db = new db_contex())
{
db.Configuration.LazyLoadingEnabled = false;
Testl tm = db.Test.Find(model.ID);
tm.Title=model.Title;
tm.Test1List=model.Test1List;
tm.Test2List=model.Test2List;
return db.SaveChanges() > 0;
}
}
catch (Exception ex)
{
CommonHelper.WriteLog("Eidt", ex.Message);
return false;
}
}