Reputation: 101
Outside of the main model I am building this list which I am them adding to a the main model that the method is returning. I wanted to know if I can do all this work inside building the main model?
Before building the main model
string Territorystring = (from p in db.Projects
join pm in db.ProjectMaterialUses on p.ProjectId equals pm.ProjectId
where projectId == p.ProjectId
select pm.Territory).FirstOrDefault();
List<string> guidStrings = TerritoryOfDistributionList.Split(',').ToList();
List<Guid> guids = guidStrings.Select(Guid.Parse).ToList();
List<Model.Country> = (from co in db.vwCountryItemDictionaries
where guids.Contains(co.CountryGUID)
select new Model.Country
{
Name = co.Name
}).ToList();
Main model
select new Project
{
TerritoryOfDistributionList = TerritoryOfDistributionList,
.....
}
Upvotes: 0
Views: 141
Reputation: 84
When your list is used client-side, I'm assuming it will be in the form of an array. If that's true, then you could always switch your csv over to a json array (assuming your territory links aren't expecting to change):
If the territory links are expected to change, you could always do version-chaining/updates via bulk sql statements.
Alternatively, you could set up a view, and read against that instead.
Upvotes: 1