我正在尝试使用RIA Services with Repository模式,每次CRUD操作都完美无缺,直到我实现了存储库。现在只有查询和提交方法正在运行。我尝试了使用和不使用Query,Insert,Update和Delete属性的方法。
有人知道问题是什么吗?
[LinqToEntitiesDomainServiceDescriptionProvider(typeof(MyEntityModelContainer))]
[EnableClientAccess()]
public class MyService : DomainService
{
internal IUnitOfWork ObjectContext { get; private set; }
public MyService(IUnitOfWork context)
{
this.ObjectContext = context;
}
public IQueryable<Employee> GetEmployees()
{
return this.ObjectContext.BusinessEntities.OfType<Employee>();
}
public void InsertEmployee(Employee employee)
{
this.ObjectContext.BusinessEntities.AddObject(employee);
}
public void UpdateEmployee(Employee currentEmployee)
{
this.ObjectContext.BusinessEntities.AttachAsModified(currentEmployee, this.ChangeSet.GetOriginal(currentEmployee));
}
public void DeleteEmployee(Employee employee)
{
if( (employee.EntityState == EntityState.Detached) )
{
this.ObjectContext.BusinessEntities.Attach(employee);
}
this.ObjectContext.BusinessEntities.DeleteObject(employee);
}
public override bool Submit(ChangeSet changeSet)
{
this.ObjectContext.Commit();
return true;
}
}
答案 0 :(得分:0)
我错误地覆盖了提交方法。