使用 LLBLGen 进行内连接?
我如何使用 LLBLGen 进行简单的连接?
table1 - clientTable(地址、电话等) table2 - 员工表(姓名等) table3 - clientEmployeeTable(clientid、employeeid)
我正在使用带有客户信息字段(地址、电话等)的employeeId 填写数据网格,但我不确定如何使用 LLBLGen 检索此数据。我想我可以创建一个存储过程,但也许有更简单的方法?
我对 LLBLGen 完全陌生。
我一直在使用存储过程,但也许有更好的方法。
// in stored proc
SELECT (my specific fields)
FROM [client].[List] abl
INNER JOIN [client].ClientGroup cg ON cg.ClientGroupId = abl.ClientGroupId
// in code
DataTable dt=RetrievalProcedures.GetEmployeeNote(EmployeeId);
rgridNotes.DataSource = dt;
How could I do a simple join using LLBLGen?
table1 - clientTable (address, phone, etc)
table2 - employeeTable (name, etc)
table3 - clientEmployeeTable (clientid, employeeid)
I'm filling out a datagrid using the employeeId with fields for the client information (address, phone, etc) and I'm not sure how I could retrieve this using LLBLGen. I suppose I could create a stored procedure but maybe there's an easier way?
I'm completely new with LLBLGen.
I've been using stored procedures meanwhile but maybe there's a better way.
// in stored proc
SELECT (my specific fields)
FROM [client].[List] abl
INNER JOIN [client].ClientGroup cg ON cg.ClientGroupId = abl.ClientGroupId
// in code
DataTable dt=RetrievalProcedures.GetEmployeeNote(EmployeeId);
rgridNotes.DataSource = dt;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
欢迎来到 LLBLGen!一旦你接受了教育,这就是很棒的产品。从各种连接表中获取信息的一种方法是使用您自己设计的类型化列表。
您的“我的特定字段”在 ResultsetFields 中定义。您的 WHERE 子句是使用 IPredicateExpression 定义的。您的 JOIN 子句由 IRelationCollection 和每个实体的 .Relations 属性出色地处理。
当尝试加快速度时,运行 SQL Server 探查器(假设您使用的是 MSSQL)是查看 LLBLGen 中的代码更改如何影响服务器请求的实际 SQL 的关键。管理 JOIN 和 WHERE 子句中的所有 () 有时需要仔细排序,但大多数时候第一次尝试就可以工作。这是我们使用的通用代码片段:
您的具体需求:
因此会变成:
虽然这似乎需要很多代码来做一些基本的事情,但一旦您习惯了,代码几乎会自己编写,并且是比编写管道要快得多。你永远不会回去。
Welcome to LLBLGen! Great product once you're schooled up. One way to get information from a variety of joined tables is with a Typed List of your own design.
Your "my specific fields" get defined in the ResultsetFields. Your WHERE clause is defined with an IPredicateExpression. Your JOIN clauses are brilliantly handled by the IRelationCollection and the .Relations properties of each Entity.
When trying to get up to speed, running the SQL Server profiler (presuming you're using MSSQL) is key to see how your code changes in LLBLGen affect the actual SQL requested from the server. Managing all of the ()'s in the JOIN and WHERE clauses sometimes requires careful ordering but most of the time works on the first try. Here's a generic snippet that we use:
Your specific need:
Would thus become:
While this seems like a lot of code to do something basic, the code almost writes itself once you're used to it and is vastly faster than writing plumbing. You'll never go back.
您可能想创建一些“相关字段上的字段”。您可以将 ClientGroup 属性添加到 Client 实体以透明地访问它们。这仅适用于 (m:1) 关系中直接相关的字段。如果您想加入更深的层次,则必须使用类型化列表。
当您获取实体并且由于 where 语句而想要连接时,您可以使用关系来连接表并构建谓词。
问候
You probably want to create some 'fields on related fields'. You can add ClientGroup properties to the Client entity to access them transparently. This only works for directly related fields in an (m:1) relation. If you want to join deeper than that, you have to use typed lists.
When you fetch entities and you want to join because of the where statement, you can use relations to join the tables and build a predicate.
Regards