Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Confused as how to get unique value of the attribute
Message
 
 
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:
01641820
Views:
33
Viv,

For the single value it worked.

However, I discovered that this code didn't work correctly:
 matrixTemplateViewModel.AllPossibleValues = _matrixTemplateValuesAdapter.GetAll().Select(v => new ValueAttribute
            {
                ValueName = v.ValueName,
                AttributeId = v.AtnameId,
                Hidden = v.Hidden
            }).Distinct().OrderBy(x=>x.AttributeId).ThenBy(y=>y.ValueName).ToList();
The list I got back contained all rows form the templates table, not just distinct values by these 3 columns.

Do you see what may be wrong here?

I also tried
var allValues = _matrixTemplateValuesAdapter.GetAll().Select(v => new ValueAttribute
            {
                ValueName = v.ValueName,
                AttributeId = v.AtnameId,
                Hidden = v.Hidden
            }).OrderBy(x=>x.AttributeId).ThenBy(y=>y.ValueName).ToList();

            matrixTemplateViewModel.AllPossibleValues = allValues.Distinct().ToList();
but still got 192 values in both lists. I am supposed to get only 95 in the second list after selecting only distinct values.

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform