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

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

 

 

你可能感兴趣的:(ResultSet)