开发者

RIA Services Entity Deletion

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 PhoneN开发者_高级运维umber from the database. How can I accomplish this?


Assuming PhoneNumbers is also an Entity on the Client side, then you can do the following:

domainContext.Employees.PhoneNumbers.Remove(phoneNumber); // remove relationship
domainContext.PhoneNumbers.Remove(phoneNumber); // remove entity
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜