开发者

linq to sql: how to create key in in orm?

I have a view that is a composition form several sources (for read only), so none of the keys are unique. Can I create a key to use in Linq-to-sql, or should I just create an 开发者_StackOverflow社区composite column in my view that is a concatenation of all the keys.


You don't have to, if you don't want to. Linq to SQL only requires primary keys when you want to update or insert data, and I guess you don't want to in a view.

You can use a simple where statement with all your keys in it to select rows:

from item in dc.SomeView
where item.Key1 = 500 && item.Key2 == "abc" && item.Key3 == 16
select item


In the end I had to create a concatenated key in the view..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜