How to create dynamic class for required Field in ADO.Net Entity FrameWork? [modified]
-
Hi, I need to create dynamic class for selected property out of all property from class. e.g class person { public string firstname{get;set;} public string middlename{get;set;} public string lastname{get;set;} public string address1{get;set;} public string address2{get;set;} public string sex{get;set;} public string dob{get;set;} } then i need onle firstname property only then i write var data=from p in objectContext.person select new{ p.firstname}.distinct(); but this code not work then what is best way for this solution
modified on Wednesday, April 27, 2011 2:44 AM
-
Hi, I need to create dynamic class for selected property out of all property from class. e.g class person { public string firstname{get;set;} public string middlename{get;set;} public string lastname{get;set;} public string address1{get;set;} public string address2{get;set;} public string sex{get;set;} public string dob{get;set;} } then i need onle firstname property only then i write var data=from p in objectContext.person select new{ p.firstname}.distinct(); but this code not work then what is best way for this solution
modified on Wednesday, April 27, 2011 2:44 AM
var data=from p in objectContext.person select new person{ firstname=p.firstname};