How come setting OrganizationName = null does not work? I am doing a union and would like to set the value to null.
from a in Activities
select new
{
a.ActivityID,
a.ActivityName,
a.OrganizationID,
OrganizationName = null
}
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 can’t actually do this:
However, you can do this:
This is because in an anonymous object it needs to be able to determine the type of that variable, and it doesn’t want to assume it is just
object. In fact for your example you may not even want that (you might want astringor a complex type e.g.Organisation). This is the same problem as going:Having said that I can’t see the utility of what you’re trying to do here so perhaps if you elaborate on your use-case a more useful answer may be found.
References: