last day (15 days later) » 

5:16 PM
0
A: How can I add Dictionary Object dynamically in LINQ?

TommyMooreIt will be like this: var q1 = resultRows.GroupBy(g => g["CustomerAccountType"]); var toLevel = q1 .Where(g => g.Key != "CustomerAccountType") .ToDictionary(g => g.Key, g => (object)g.Sum(s => Convert.ToDecimal(s[g.Key]))); toLevel.Add("AccountGroupName", q1 ...

 
This is close to what I need but there is a syntax error "Cannot convert lamba expression to type'System.Collections.Generic.IEqualityComparer<object>' because it is not a delegate type
I do not have a strongly typed object by the way because the collection will be dynamic
 
I Compiled that with this on definition: var resultRows = new List<Dictionary<string, string>>();
Do you think you can do necessary tweaks for your dynamic collection?
 
Exactly. here is my variable declaration List<Dictionary<string, object>> resultRows = new List<Dictionary<string, object>>();
 
If you give me your expected dynamic type resultRows I can fix that for you.
 
I created a complete gist on github gist.github.com/agentpx/f34de8fac56bba1e2f67
 
5:16 PM
are u sure you want group this by value of object?
resultRows.GroupBy(g => g["CustomerAccountType"]);
 
Yes, Thank for your time by the way
this is how resultRows are constructed
for (int i = 0; i < cols.Count - 1; i++)
{
resultRow = new Dictionary<string, object>();
resultRow.Add("CustomerAccountType", cols[0].ToString());
resultRow.Add("CustomerCategory", cols[1].ToString());
resultRow.Add("CustomerEstablishment", cols[2].ToString());
resultRow.Add("CustomerEstablishmentType", cols[3].ToString());
resultRow.Add("CustomerName", cols[4].ToString());
int k = 0;
for (int j = 5; j < cols.Count - 1; j++)
{
k++;
resultRow.Add("Actual" + k.ToString().Trim(), Convert.ToInt64(cols[j]));
cols[n] came from cubes result
Are Image allowed to be pasted here in chat?
This is why I wanna group it into hierarchy postimg.org/image/sy84evt6r
Oh sorry about the site Ads...lol
 
5:57 PM
u still there tommy?
I gtg now, thanks for your time. going to sleep now..bye
 

last day (15 days later) »