在linQ查询中创建列表

问题描述 投票:0回答:1

我有以下DTO:

public class ContinentScopeDto
{
    public string Name { get; set; }
    public long? ContinentId { get; set; }
    public List<CountryScopeDto> CountriessPairList { get; set; }
}

CountryScopeDto模型如下:

public class CountryScopeDto
{
    public string CountryName { get; set; }
    public long? CountryId { get; set; }
}

我希望能够选择大陆名称和ID以及相关国家/地区列表。

我的linq查询如下:

 var query = (from branch in this.DataAccess.GetOperations<PA_BRANCHES>().FindAll(item => silosBranch.Contains(item.Id))
                     join country in this.DataAccess.GetOperations<PA_LIST_OF_COUNTRIES>().FindAll()
                     on branch.COU_N_ID equals country.Id
                     join countryTrad in this.DataAccess.GetOperations<PA_LIST_OF_COUNTRIES_TRAD>().FindAll(item => item.LANG_CH_TAG.Equals(userlang))
                     on country.Id equals countryTrad.COU_N_ID
                     join continentTrad in this.DataAccess.GetOperations<PA_LIST_OF_CONTINENTS_TRAD>().FindAll(item => item.LANG_CH_TAG.Equals(userlang))
                     on country.CONT_N_ID equals continentTrad.CONT_N_ID
                     select new ContinentScopeDto
                     {
                         Name = continentTrad.TONT_CH_LABEL,
                         ContinentId = continentTrad.CONT_N_ID,
                         CountriessPairList = new List<CountryScopeDto>
                         {

                         }
                     }

            );

在这里,我不知道如何创建该大陆的国家名单。

我的查询应该返回与其国家/地区的大陆列表。

任何帮助请。

sql-server linq
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.