在ExecuteStoreQuery方面需要帮助 [英] Need help with ExecuteStoreQuery
问题描述
我得到了一个linq查询,并且正在使用ExecuteStoreQuery将其写入sql查询中,例如我的linq查询是:
var 详细信息= 来自 empDetails 在 exDataContext.EmployeeEntity
加入 depDetails in 中empDetails.dmpId上的exDataContext.DeptEntity等于depDetails.depId 选择 新 {empDetails.EmpName,empDetails.Salary,empDetails.OrganizationEntity
}
// ------------------------ -------------
字符串 sqlQuery =(" { 0 },参数)
现在,我定义了具有属性EmpName{get;set;} Salary{get;set;}
的属性类,现在我的问题是:
看到在选择新括号的下面,我选择了empDetails.EmpName, empDetails.Salary, empDetails.OrganizationEntity
,并且我已经定义了在一个类中为EmpName和Salary设置的属性,现在我该如何为OrganizationEntity定义属性,因为它是一个表?
我的CS文件是:
公共 静态 字符串 EmpName {获取; set ;}
公共 静态 字符串工资{获取; 设置;}
现在,我该如何提及OrganizationEntity,因为它是一个表.
Linq不返回表,它返回对象或实体.因此,您需要创建一个由OrganizationEntity表示的对象类型的属性.如果它本身是一个实体,则该属性将是实体类的类型.变化
Hi,
I got a linq query and i am writing it into sql query using ExecuteStoreQuery for eg my linq query is:
var details = from empDetails in exDataContext.EmployeeEntity
join depDetails in exDataContext.DeptEntity on empDetails.dmpId equals depDetails.depId where (some condition)
select new{ empDetails.EmpName, empDetails.Salary, empDetails.OrganizationEntity
}
//-------------------------------------
string sqlQuery= ("Select ..... "{0},args)
Now I have defined a properite class witht properties EmpName{get;set;} Salary{get;set;}
, now my question is:
See under in the select new braces, I have selected empDetails.EmpName, empDetails.Salary, empDetails.OrganizationEntity
, and i have defined properties get set for EmpName and Salary in one class, now how could I define properties for OrganizationEntity since it is a table?
my cs file is:
public static string EmpName{get;set;}
public static string Salary {get;set;}
Now how can I mention the OrganizationEntity since it is a table.
Linq does not return tables it returns objects, or Entities. So you would need to create a property of the type of object OrganizationEntity represents. if it is an entity itself the property would of be type of the entity class.
should i define properties for each column in organizationentity, if that is the case i have to make lot of code changes
这篇关于在ExecuteStoreQuery方面需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!