实体SQL-Linq to Objects方法 [英] Entity SQL - Linq to Objects Method

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

问题描述

我正在尝试编写一种Linq方法,该方法将允许我传递参数.
在下面的示例中,我正在访问存储过程.然后,我将在客户端调用此方法.

I am trying to write a Linq method that will allow me to pass in parameters.
In the following example, I am accessing a stored procedure. I will then call this method on the client side.

Public Function GetContractData(ByVal contract As String) As IQueryable(Of bdis_ContractSearch2_Result)
        Return Me.ObjectContext.GetContractData.where(Function (cntr)=> cntr.contract).[Select](Function(cntr) New _
                                            APP07_20_2010.Web.DataEntities() with{ _
                      .Contract = cntr.Contract,_
                      .ContractDesc = cntr.ContractDesc, _
                      .ClientName = cntr.ClientName, _
                      .ProjMgrName = cntr.ProjMgrName, _
                      .Status = cntr.Status, _
                      .EndDate = cntr.EndDate, _
                      }).AsQuerable()


有人可以帮助我正确设置此方法的格式吗?


Can someone help me correctly format this method?

推荐答案

HI
使用存储过程时,它将充当本地作用域.
所以我认为,最好在调用存储过程时填充一个表,然后使用linq查询该表.

返回类型必须是该类类型
HI
When you are using a stored procedure it will act as local scope.
So I think , it is better to fill a table when calling the store procedure.And query that table using linq.

The return type must be that class type


这篇关于实体SQL-Linq to Objects方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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