Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Confused as how to get unique value of the attribute
Message
From
10/10/2016 09:54:17
 
General information
Forum:
ASP.NET
Category:
LINQ
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01641789
Message ID:
01641790
Views:
30
>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();
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform