在另一个实体中查找值 [英] Looking up a value from another entity

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

问题描述

大家好

我在LS2013中遇到问题.我有一个称为时间表的实体.字段之一是一个称为SerialNo的int.这对应于另一个实体中的String(不用问,不能更改,但是所有新值都将是int).

I'm stuck on a problem in LS2013. I have an entity called timesheets. One of the fields is an int called SerialNo. This corresponds to String (don't ask, it can't be changed, but all new values will be ints) in another entity.

当用户输入序列号时,我想根据序列号为另一个实体查找另一个值(seqNo).理想情况下,我希望将其显示在标签中,但看不到如何显示.我至少需要它来进行验证.

When the user enters a serial no, I want to lookup another value (seqNo) for the other entity based on SerialNo. Ideally, I'd like to display it in a label, but can't see how. I need it for validation at least.

这不成问题:只需创建一个传递序列号的查询,然后将结果分配给本地属性即可.问题是,我无法将参数(字符串)绑定到时间表序列号no字段,因为其为int且查询需要一个字符串. 在参数绑定中,无法进行强制转换(我可以找到).那么我可以在代码中进行绑定(以便进行必要的强制转换吗?

Didn't think it would be a problem: just create a query passing the serial no and assign the result to a local property. Problem is, I can't bind the parameter (an string) to the timesheet serial no field because its an int and the query wants a string. In parameter binding there's no way to do a cast (that I can find). So can I do the binding in code (so I do the necessary cast?

我写了一个linq查询,该查询可以执行我想要的操作(如下),但是不知道如何在LS中使用它

I wrote a linq query that does what I want (below), but don't know how to use it in LS

var SeqNo =
                    (from i in Items
                     where i.JobID == 226
					 && i.SerialNo == "5021635173"
                     select i.SeqNo).Take(1);
					 SeqNo.Dump();
					 
					 int? SeqNoFound;
 
                SeqNoFound = SeqNo.FirstOrDefault();
				SeqNoFound.Dump();

任何人都可以为我指出正确的方向吗?

Can anyone point me right direction?

谢谢

标记

Mark

推荐答案

如果您想使用上面的代码编写查询事件,此演示是一个很好的开始.

If you want to write query event using code above, this demo is good start.

  1. 解决方案资源管理器中,展开"数据源"节点,展开所需的数据源节点,然后双击一个实体或表(例如: 联系).

  1. In Solution Explorer, expand the Data Sources node, expand the desired data source node, and then double-click an entity or table (For example: Contact).

数据设计器打开.

数据设计器命令栏上,单击 查询.

On the Command Bar of the Data Designer, click Query.

代表查询的节点将添加到 Solution Explorer ,查询将在 查询设计器.

A node that represents the query is added to Solution Explorer and the query opens in the Query Designer.


这篇关于在另一个实体中查找值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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