开发者

EF 4.1 skip dictionary tables for member collection

It's a little bit hard to find an appropriate title for this.

I think it's a basic issue, but I can't find the solution.

public class Car
{
  ...
  public ICollection<Parts> Parts { get; set; }
}

public class Parts
{
  ...
}

The application has a "repository" or "catalog" for parts. When I edit a car entity I can choose from this repository to add a part.

I have two problems with the default mapping:

  1. I want to able to delete a part a from the catalog without deleting it from the car.
  2. If I add a part only to a car manually, i开发者_StackOverflow社区t will appear in the "catalog" which shouldn't.

In other words I want separate Parts db tables:

1. For the parts which related to specific cars (Parts (collection) member of Car class) 2. For the catalog to choose from

Thanks in advance


Add a column to the Parts entity called "ShowInCatalog" and set it to 0 for the ones you don't want to show up in your catalog (thus the catalog will do a query to get everything with that value at 1).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜