How do I get MS LightSwitch to recognize my View?

亡梦爱人 提交于 2019-12-06 12:13:33
stephan

for lightswitch to see your view you must have a primary key on a column of the table your are selecting from. Example:

create table tbl_test
(
id int identity primary key not null,
value varchar(50)
)

create view vw_test
as
select *
from tbl_test

note:sometimes when you edit the primary key column in the view select statement it may cause lightswitch to not see it

Example:

create view vw_test
 select cast(id as varchar(50) id,...

lightswitch would not see the table

Hope this was helpful! :)

What I do in this case is create a view with an ID column equal to the row number. Ensure the column you're basing the ID on is not null using the isnull() or coalesce() functions.

Example:

create view as
select distinct ID = row_number() over (order by isnull(Name,'')), 
Name = isnull(Name,'')
from My_Table
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!