Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 linq 中选择 NULL 作为列选项。
我的 sql 会读取。
Select field1, field2, field3, null as "null", field4 from table1
我的 linq 查询将是:
from t in table1 select new { t.field1, t.field2, t.field3, null as "null", t.field4}
视觉工作室产生的错误是:
无法分配给匿名类型属性
删除as "null"并命名参数,将其转换null为它的类型:
as "null"
null
from t in table1 select new { t.field1, t.field2, t.field3, someField = (string)null, t.field4}