I have such Linq, I would like to get all records from Orders table and also add new dynamic field. The code below do not work. What is correct syntax?
user.dcOrders.Select(p =>p, new { FullName = p.FirstName + " " + p.LastName })
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ll need to list out all the columns.
Alternatively you could add a new property to whatever class
dcOrdersis. It should be specified as apartial classso you can add theFullNameproperty to a new file so it doesn’t get overwritten when the.designer.csfile is regenerated.So something like
Be sure to add this to a separate file not the
.designer.csfile. (I’m assuming LINQ to SQL here).Then you don’t need to do any special select, because
FullNamewill already exist as a property on the object. You can just use it directly.