public static class MyExtensions
{
public static IEnumerable
this IEnumerable
Func
{
var results = new List
foreach (var s in source)
if (filter(s))
results.Add(s);
return results;
}
}
private double? GetConvertedPrice(RealEstate realEstate)
{
return realEstate.Price * exchangeRates[realEstate.PriceCurrencyId.Value - 1].Value;
}
var realEstates = _db.RealEstates.SelectWhere(re =>
(re.CategoryId == null || catId == null || re.CategoryId == catId)
&& (re.TypeId == null || typeId == null || re.TypeId == typeId)
&& (re.CityId == null || cityId == null || re.CityId == cityId)
&& (re.DistrictId == null || districtId == null || re.DistrictId == districtId)
&& (re.Price == null || priceMin == null || GetConvertedPrice(re) >= priceMin)
&& (re.Price == null || priceMax == null || GetConvertedPrice(re) <= priceMax)
);
http://msdn.microsoft.com/en-us/library/bb383977.aspx
extension methods in linq
Gönderen
pantepember
4 Mayıs 2010 Salı
Etiketler: extension methods in linq , linq