0
我有默認值定義我StateRegions屬性的默認值的屬性之一返回一個列表,例如:使用LINQ to從比較兩個列表,其中
public string Vermont
{
get
{
return string.IsNullOrEmpty(_region) ? "NorthEast" : _region;
}
set { _region = value; }
}
public string NewHampshire
{
get
{
return string.IsNullOrEmpty(_region) ? "NorthEast" : _region;
}
set { _region = value; }
}
public string Massachusetts
{
get
{
return string.IsNullOrEmpty(_region) ? "NorthEast" : _region;
}
set { _region = value; }
}
public string RhodeIsland
{
get
{
return string.IsNullOrEmpty(_region) ? "NorthEast" : _region;
}
set { _region = value; }
}
public string NewYork
{
get
{
return string.IsNullOrEmpty(_region) ? "NorthEast" : _region;
}
set { _region = value; }
}
public string Pennsylvania
{
get
{
return string.IsNullOrEmpty(_region) ? "NorthEast" : _region;
}
set { _region = value; }
}
現在我想建立一個基於該區域的列表在DB中聲明。這是基本的代碼/僞代碼:
// 1) What states have customers?
List<string> states = GetStatesHavingCustomers();
// 2) What are the regions that correspond to US States?
List<StateRegions> regions = new List<StateRegions>();
// Lets get the get the states in the DB and
// put the corresponding regions in a list
任何想法如何在LINQ中做到這一點?