linq表达与任何地方

时间:2015-12-17 11:53:47

标签: c# .net linq

我有模特

public class MyModel
{
   public List<Car>Cars {get; set;}
   public int? SomeId {get; set;}
   ...     
}
public class Car
{
   ...
   public int? FormatId {get; set;}  
}

在linq表达式中我想获取MyModel对象的列表,其中的FormatId等于MyModel中的SomeId

var q = model.Cars.Where(x=>x.FormatId.HasValue && x.FormatId == model.SomeId)
.how to select here?);

1 个答案:

答案 0 :(得分:2)

好吧,如果想要<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> <div class="container"> <div class="row"> <div class="col-md-4 extra1"> <div class="your-things"> <p>.col-md-4</p> </div> </div> <div class="col-md-8 extra2"> <div class="your-things"> <p>.col-md-8</p> </div> </div> </div> </div>为您的现有查询添加List<Car>,或者假设您有名为ToList()的{​​{1}}列表,则可以执行以下操作:

MyModel