RIA 服务实体删除
我有一个 DomainService,我正在尝试从中删除记录。
假设以下粗略代码服务器端方法:
public IQueryable<Employee> GetAllEmployees()
{
DataLoadOptions loadOpts = new DataLoadOptions();
loadOpts.LoadWith<Models.Employee>(e => e.PhoneNumber);
this.DataContext.LoadOptions = loadOpts;
return this.DataContext.Employees;
}
这意味着当我加载所有员工时,他们的所有电话号码都包含在内。
我可以执行以下客户端代码,其中 phoneNumber 是一个实体:
domainContext.Employees.PhoneNumbers.Remove(phoneNumber);
据我了解,这删除了 Employee 和 PhoneNumber 实体之间的关系,但我真正想要的是是从数据库中完全删除 PhoneNumber。我怎样才能做到这一点?
I have a DomainService which I am trying to delete records from.
Assuming the following rough code server-side method:
public IQueryable<Employee> GetAllEmployees()
{
DataLoadOptions loadOpts = new DataLoadOptions();
loadOpts.LoadWith<Models.Employee>(e => e.PhoneNumber);
this.DataContext.LoadOptions = loadOpts;
return this.DataContext.Employees;
}
This means that when I load all my employees, all their Phone Numbers are included.
I can do the following client side code, with phoneNumber being an entity:
domainContext.Employees.PhoneNumbers.Remove(phoneNumber);
This, as I understand it, removes the relationship between Employee and PhoneNumber entitities, but what I really want is the complete removal of PhoneNumber from the database. How can I accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设
PhoneNumbers
也是客户端的实体,那么您可以执行以下操作:Assuming
PhoneNumbers
is also an Entity on the Client side, then you can do the following: