c# - Set linq return property to null -


How is the setting OrganizationName = null not working? I am making a union and I would like to set the value to null .

Activity from a new activity, a. Activivinization, A. Organization ID, Organization name = Null}

You can not really do this: < / P>

This is a compile-time error for the expression in the unknown object initializer to be of empty type.

However, you can do this:

Select one of the activities, new {a.ActivityID, a.ActivityName, a.OrganizationID, OrganizationName = (object) The reason for this is that in an unknown object it needs to be able to determine the type of variable, and do not want to believe it is only Object is really you can not do this for your example (you can use a string or a complex type like organization f Week are). This is the same problem as knowing:

  var a = null; / * What is the cruelty of the world? /  

After saying that you are trying to use here, so perhaps if you have a more useful answer in your use case can be found.

Reference:


Comments