开发者

Linq to SQL inheritance and Table per Class - approach needed for multiple roles

I am using L2S and an inheritance model for mapping Persons against certain roles.

Guy Burstein's excellent blog post explains how to accomplish this:

http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/10/01/linq-to-sql-inheritance.aspx

However, I have a specific case where a Person has multiple roles. For example 'Jane Doe' is a Contact and a Programmer. In 开发者_Python百科this model, she would need two rows in the People table, one as Contact (PersonType = 1) and one as Programmer (PersonType = 3).

If she changes her last name, and that update happens in her role as Contact, I would need to change all instances of 'Jane Doe' to reflect the name change everywhere.

What sort of best approach (improved data structure) could be used to change last name within all roles? Finally, I am hoping to avoid overriding each general form update events to include all instances, but that may be the only way. Any suggestions or approaches appreciated.


From what I can tell from the information you provided your database should have three tables:

  1. People
  2. Programmers
  3. Contacts

Programmers and Contacts should have a foreign-key Person_fK.

In the object model Programmer and Contact would each have a Person property.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜