.net CUD方法赢得';t火
我正在尝试将RIA服务与存储库模式结合使用,在我实现存储库之前,每个CRUD操作都能完美地工作。现在只有查询和提交方法在工作。我尝试了使用和不使用查询、插入、更新和删除属性的方法 有人知道问题出在哪里吗.net CUD方法赢得';t火,.net,wcf-ria-services,.net,Wcf Ria Services,我正在尝试将RIA服务与存储库模式结合使用,在我实现存储库之前,每个CRUD操作都能完美地工作。现在只有查询和提交方法在工作。我尝试了使用和不使用查询、插入、更新和删除属性的方法 有人知道问题出在哪里吗 [LinqToEntitiesDomainServiceDescriptionProvider(typeof(MyEntityModelContainer))] [EnableClientAccess()] public class MyService : DomainService {
[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;
}
}
[LinqToEntitiesDomainServiceDescriptionProvider(typeof(MyEntityModelContainer))]
[EnableClientAccess()]
公共类MyService:DomainService
{
内部IUnitOfWork对象上下文{get;private set;}
公共MyService(IUnitOfWork上下文)
{
this.ObjectContext=context;
}
公共IQueryable GetEmployees()
{
返回此.ObjectContext.BusinessEntities.OfType();
}
公共无效插入员工(员工)
{
this.ObjectContext.BusinessEntities.AddObject(employee);
}
public void UpdateEmployee(Employee currentEmployee)
{
this.ObjectContext.BusinessEntities.AttachAsModified(currentEmployee,this.ChangeSet.GetOriginal(currentEmployee));
}
公共作废删除员工(员工)
{
if((employee.EntityState==EntityState.Detached))
{
this.ObjectContext.BusinessEntities.Attach(employee);
}
this.ObjectContext.BusinessEntities.DeleteObject(employee);
}
公共覆盖布尔提交(变更集变更集)
{
this.ObjectContext.Commit();
返回true;
}
}
我错误地改写了提交方法