本文介绍了如何让 MS LightSwitch 识别我的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从另一个数据库中的表创建了一个视图.我拥有数据库的 dbo 权限,因此查看和更新​​不是问题.这个特定的视图没有id"列.所以我使用 ROW_NUMBER 在视图中添加了一个.现在我在同一个数据库中的表有问题,没有显示在 LightSwitch 中,但通过将 id 列更改为 NOT NULL 解决了这个问题.我还没有在 LightSwitch 中进行任何真正的操作.我仍处于导入您的数据源阶段(即一开始).

I've created a View from a table in another database. I have dbo rights to the databases so viewing and updating is not a problem. This particular View did not have an "id" column. So I added one to the View by using ROW_NUMBER. Now I had a problem with a table, in the same database, not showing up in LightSwitch but that was solved by changing the id column to be NOT NULL. I haven't done any real manipulation in LightSwitch. I'm still in the Import Your Data Source stage (ie. very beginning).

LightSwitch 中的此视图将是只读的.没有更新或删除.据我所知,LightSwitch 需要一种方法来确定表或视图的 PK.它要么从模式中读取它(列设置为 PK),要么查找设置为 NOT NULL 的列并将其用作 PK.好吧,我似乎无法在 SQL Server 或 LightSwitch 中做这些事情,所以我不知道如何让 LightSwitch看到"我的视图.

This View, in LightSwitch, is going to be read-only. No updating or deleting. From what I've read, LightSwitch needs a way to determine the PK of a Table or View. It either reads it from the schema (column set as a PK) or finds a column set as NOT NULL and uses that as the PK. Well I can't seem to do either of those things in SQL Server or LightSwitch, so I am stuck as to how to get LightSwitch to "see" my View.

推荐答案

要使 lightswitch 看到您的视图,您必须在要从中选择的表的列上有一个主键.示例:

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

注意:有时在view select语句中编辑主键列可能会导致lightswitch看不到

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

示例:

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

灯开关看不到桌子

希望这有帮助!:)

这篇关于如何让 MS LightSwitch 识别我的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 08:41