Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I got a linq query and i am writing it into sql query using ExecuteStoreQuery for eg my linq query is:
C#
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:
C#
public static string EmpName{get;set;}

public static string Salary {get;set;}

Now how can I mention the OrganizationEntity since it is a table.
Posted
Updated 27-Jan-11 18:49pm
v2

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.
 
Share this answer
 
should i define properties for each column in organizationentity, if that is the case i have to make lot of code changes
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900