Entity Framework: 檢視查詢時重複返回第一行值, duplicate frst rows in resultset from a view

zyip發表於2014-04-01

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

 

 

相關文章