Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Confused as how to get unique value of the attribute
Message
De
10/10/2016 09:54:17
 
 
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Divers
Thread ID:
01641789
Message ID:
01641790
Vues:
31
>Hi everybody,
>
>I am trying the following code that doesn't compile:
>
>
>matrixTemplateViewModel.TemplateValues = _matrixTemplateValuesAdapter.GetTemplates(id).OrderBy(v => v.TmplOrder).ToList();
>
>            matrixTemplateViewModel.RowAttributeId = matrixTemplate.PrimAxis;
>            matrixTemplateViewModel.ColumnAttributeId = matrixTemplateViewModel.TemplateValues.Where(x=>x.AtnameId!=matrixTemplate.PrimAxis).
>                
>                Select(x => new { x.AtnameId }).Distinct().FirstOrDefault();
>
>The TemplateValues is a list of ITmplat which has the following column of interest AtnameId. There should be two unique values in the whole set since that table represents Rows and Columns with their values.
>
>I know the Row AtnameId (which is PrimAxis column in the other template (matrixTemplate.PrimAxis). I need to get the other attribute value for the Column which would be the distinct value of AtnameId different from PrimAxis.
>
>So, this is the idea of my last statement but it doesn't work. Can you please help with the LINQ syntax?
>
>Thanks in advance.

Too hard to fathom from your description. What is the error ?
Also I'd suggest splitting the query so that (a) you can better identify where the error lies and (b) inspect the intermediate results:
tmp = matrixTemplateViewModel.TemplateValues.Where(x=>x.AtnameId!=matrixTemplate.PrimAxis);
               
matrixTemplateViewModel.ColumnAttributeId  = tmp.Select(x => new { x.AtnameId }).Distinct().FirstOrDefault();
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform