0
我正在嘗試將RIA Services與Repository模式一起使用,每次CRUD操作都完美運行,直到我實現了存儲庫。現在只有查詢和提交方法正在工作。我嘗試了有和沒有查詢,插入,更新和刪除屬性的方法。CUD方法不會觸發
有誰知道問題是什麼?
[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;
}
}