所以我有点卡在下面的 linq 语句上,
public void ReturnHire(string carregistration, string hirefromdate, string hiretodate)
{
var result = customermembers.Where(c => c.CustomerCarType.Where(n => String.Equals(n.CarRegistration, carregistration)).FirstOrDefault(); // this line
if (result != null)
{
customermembers.ForEach(c => c.CustomerHireDate.RemoveAll(cs => cs.HireFromDate == hirefromdate && cs.HireToDate == hiretodate));
customermembers.ForEach(c => c.CustomerCarType.RemoveAll(cs => cs.CarRegistration == carregistration));
}
}
我的 xml 看起来像这样:
<ArrayOfCustomer>
<Customer>
<CustomerID>1</CustomerID>
<FirstName>G</FirstName>
<LastName>Graam</LastName>
<Age>27</Age>
<CustomerHireDate>
<HireDate>
<HireFromDate>15.07.2012</HireFromDate>
<HireToDate>29.07.2012</HireToDate>
</HireDate>
</CustomerHireDate>
<CustomerCarType>
<CarType>
<CarRegistration>IAWB-OOTO</CarRegistration>
</CarType>
</CustomerCarType>
</Customer>
</ArrayOfCustomer>
在我的客户端,客户要“归还”车辆,对我来说,这基本上只是从日期和日期中删除租用,并从客户内部删除注册号。但这是我必须只用注册号进行删除的问题,所以我试图在 where 子句中做一个 where 但它说我不能将 CarType 隐式转换为 bool。
我的网络服务有这些列表:
List<Customer> customermembers = new List<Customer>();
List<HireDate> hiredates = new List<HireDate>();
List<CarType> cartypes = new List<CarType>();
我只是觉得customermembers where customer car type where rehistration number equals mystring
会很好?