我不知道如何解釋清楚。但是我試圖在LINQ語句執行時獲得另一個屬性。 例如:執行LINQ時獲取另一個對象
這是一個工作LINQ聲明:
if (customerData.Demographics.Count > 0)
{
string[] communities = {"ONLINE_TECH_COMM", "ONLINE_PROF_NET", "ONLINE_TECH_SECTIONS"};
var results = (from CustomerDemographic customerDemographic in customerData.Demographics where (customerDemographic.UserD2==DateTime.MinValue)
select new Models.MemberOnlineCommunityPreferences()
{
DemographicCode = customerDemographic.DemographicCodeString,
DemographicSubCode = customerDemographic.DemographicSubcodeString,
}).Where(x=>communities.Contains(x.DemographicCode)).OrderBy(x=>x.DemographicCode).ToList();
現在,我需要通過DemographicCodeString
和DemographicSubcodeString
值
oApplicationSubcode = TIMSS.API.CachedApplicationData.ApplicationDataCache.get_ApplicationSubCode("CUS", "DEMOGRAPHIC", DemographicCodeString, DemographicSubcodeString);
而且,檢查性能WebEnabled =="Y"
和Active=="Y"
,然後只讀customerData
並將其分配給結果。是否可以在單個語句中使用LINQ來完成此操作?
如果我理解正確的話,'WebEnabled'和'Active'從'oApplicationSubcode'屬性,則需要檢查它們是否'每個Y''MemberOnlineCommunityPreferences'對象?如果這是真的,我想你可以在where子句中包含方法調用'get_ApplicationSubCode'並在那裏過濾? –