查看视图 [英] Lookup views

查看:86
本文介绍了查看视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何处理LightSwitch中的以下内容。我有一个名为Product(ProductID,...)的表和一个名为ProductDescription(ProductID,ProductDescription)的视图。我希望为任何具有ProductID
外键的表显示ProductDescription。

I'm wondering how I could handle the following in LightSwitch. I have a table called Product (ProductID, ...) and a view called ProductDescription (ProductID, ProductDescription). I would like ProductDescription to be displayed for any tables that have ProductID foreign keys.

当我尝试创建关系时,我收到一条错误消息"无法添加关系'ProductPriceList'和'ProductDescription',因为它们位于同一容器中。"知道如何解决它?

When I try and create the relationship I get an error message "Cannot add a relationship between 'ProductPriceList' and 'ProductDescription', because they are in the same container." Any idea how to resolve it?

推荐答案

您不需要为此添加其他关系。 只要您拥有ProductPriceList和Product表之间的关系, 以及Product和ProductDescription表之间的关系。

You don't need add another relationship for this.  As long as you have the relationship between ProductPriceList and Product table,  and a relationship between Product and ProductDescription table.

将所有3个表导入LightSwitch后。

After you import all 3 tables into the LightSwitch.

现在,编辑Product表,添加一个新字符串字段并将其命名为Description。 LightSwitch产品不允许您更改附加表的架构。 因此,新字段将是计算属性。

Now, edit the Product table, add a new string field and call it Description. The LightSwitch product doesn't allow you to change the schema of an attached table.  So the new Field will be a computed property.

选择该字段,在属性表中,您可以找到添加计算代码的链接。单击该链接,您可以添加代码:

Select that field, and in the property sheet, you can find a link to add computation code. Click the link, you can add code:

result = Me.ProductDescription.Description

result = Me.ProductDescription.Description

这会将ProductDescription表中的值拉到产品表。

This will pull the value from the ProductDescription table to the Product table.

现在,返回设计师并再次编辑Product表。 选择标题(表格本身),在属性表中,您可以找到一个组合框来选择摘要属性。 将ComboBox的值更改为刚刚添加
的新计算字段。

Now, go back to the designer and edit the Product table again.  Select the Title (the table itself), in the property sheet, you can find a combo box to select summary property.  Change the value of the ComboBox to the new computed field you just added.

现在,编译并运行应用程序。 您将看到描述将显示在产品的任何位置。

Now, compile and run the application.  You will see the Description will be shown anywhere a product should be.

 


这篇关于查看视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆