Entity Framework: 视图查询时重复返回第一行值, duplicate frst rows in resultset from a view

http://blog.csdn.net/riverlau/article/details/7476449

 

1. 使用rownumber给view加上一个标示列

SELECT     ROW_NUMBER() OVER (ORDER BY appid) AS id, *
FROM         (SELECT     appid, 'NewsLetterService:' + CONVERT(nvarchar(8), id) AS moduleID, ServiceName AS moduleName
                       FROM          NewsLetterService
                       UNION
                       SELECT     appid, 'Modules:' + CONVERT(nvarchar(8), ID) AS moduleID, ModuleName
                       FROM         Modules) a

 

2. 在模型中把该列的Enitty Key属性设置为True

 

 

posted @ 2014-04-01 08:53  zyip  阅读(350)  评论(0编辑  收藏  举报