如何在linq中选择NULL作为列选项.
我的sql会读.
Select field1, field2, field3, null as "null", field4
from table1
Run Code Online (Sandbox Code Playgroud)
我的linq查询将是:
from t in table1
select new { t.field1, t.field2, t.field3, null as "null", t.field4}
Run Code Online (Sandbox Code Playgroud)
visual studio生成的错误是:
无法分配给匿名类型属性
删除as "null"并命名参数,将其null转换为其类型:
from t in table1
select new { t.field1, t.field2, t.field3, someField = (string)null, t.field4}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
769 次 |
| 最近记录: |