开发者

EF4 - Foreach local variable with static data

开发者 https://www.devze.com 2023-01-20 00:27 出处:网络
I\'m us开发者_运维百科ing EF4. I\'ve found a very annoying issue. I have a db view that I\'ve dragged into my Entity Model class.

I'm us开发者_运维百科ing EF4. I've found a very annoying issue.

I have a db view that I've dragged into my Entity Model class. When I try to iterate over the hole collection, the data displayed, it's almost the same that the first objects... I've tried enabling Lazy Loading, but nothing works.. it's a really simple snippet.. why doesn't work???

Dal.Entities context = new Dal.Entities();                
list = context.vw_Full_Poll.ToList();

foreach (var item in list)
                {
                    PrintPoll(htmlWriter, item);
                }


You haven't defined a PK for the view. Since DB VIEWs don't have PKs, the EF can't derive this automatically.

0

精彩评论

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