正文
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