以非常简单的术语,我想在某些情况下将字符串分配给变量。我试图把if语句放在全局变量的linq语句的外部,但是然后它通过if /然后将字符串赋值给变量,然后在我的excel文件中为每一行打印出来产生的。如果/然后在Linq声明
让我怎么把类似这样的
var status = "";
if(_db.Owners.Select(i => i.Item1) != null && _db.Owners.Select(i => i.Item2) == null)
{
status = "S";
}
到我的LINQ语句声明说类似于这样
return _db.Owners
.Select(owner => new
{
CustomerId = owner.Report.CustomerId,
IdType = status,//I want this statement to print that status S only where the statement is true
}
你只想与状态项目= S的返回的集合,或者你只希望在那种情况下打印*? – BradleyDotNET
我不知道我是否正确 - 你只需要'Item1!= null'和'Item2 == null'的'owner'对象以状态S打印?其他记录怎么样 - 他们有什么状态? –