score:3
Accepted answer
You cannot define property names of anonymous types as strings:
I have defined two classes to get your info together:
internal class Entry
{
public string SystemUser { get; set; }
public string HostName { get; set; }
public string DIMSUser { get; set; }
public string EntryDetails { get; set; }
public string AssetName { get; set; }
public string EntryDate { get; set; }
public string EntryTime { get; set; }
}
internal class UserEntryPerDateInfo
{
public string DIMSUser { get; set; }
public string EntryDate { get; set; }
public IEnumerable<Entry> EntryList { get; set; }
}
Here you populate your data:
IEnumerable<Entry> dataList = from d in dataTableResults.AsEnumerable()
select new Entry
{
SystemUser=d["SystemUser"],
HostName=d["Host Name"],
DIMSUser=d["DIMS User"],
EntryDetails=d["Entry Details"],
AssetName=d["Asset Name"],
EntryDate=d["Entry Date"],
EntryTime=d["Entry Time"],
};
Then you group by date and user and get them in another class:
IEnumerable<UserEntryPerDateInfo> result = from a in dataList
group a by new {User = a.DIMSUser, EntryDate = a.EntryDate}
into grouped
select
new UserEntryPerDateInfo
{
DIMSUser = grouped.Key.User,
EntryDate = grouped.Key.EntryDate,
EntryList = grouped
};
Source: stackoverflow.com
Related Query
- Nested Group by LINQ
- LINQ to DataSet case insensitive group by
- Group by multiple columns linq count nested row
- LINQ Source Code Available
- C# Triple Nested Linq Group
- LINQ and group by data nested within a structure
- creating Linq to sqlite dbml from DbLinq source code
- Linq group by to create nested listview
- Group nested list with linq
- How can I access the group of a linq group-by query from a nested repeater control?
- Nested Linq Group By
- Dynamic linq nested group
- Nested group with LINQ
- Linq to DataSet, Nested Group By?
- Linq to SQL Nested Select Group by Having count
- LINQ to DataSet Group By Multiple Columns - Method Syntax
- Linq nested group by to manipulate identity data
- How to Select top (5) contributors group by Business type code in c# linq query
- How can I code numerous MIN functions into one LINQ to DataSet query
- replace 3 levels of nested for loops by efficient code possibly linq
- LINQ Group by on multiple tables with nested group by with join and aggregate
- source code for LINQ 101 samples
- LINQ Group Nested List To Restructure Data
- linq nested group by
- linq group by to generate nested POCO
- LINQ Group by of Nested object value and repeat Parent object
- Group by linq for nested objects
- Linq nested Join from a group join if null
- Nested select with group by using linq
- Linq group with sum function and nested records
More Query from same tag
- Getting all attribute values from node by specifying the ancestor node using LINQ
- List of Users with list of Roles in Identity 2.2.1
- C# console input
- LINQ OrderBy. Does it always return the same ordered list?
- Return a list instead of IQueryable
- Linq filter parent objects based on child objects collection
- Find matching items by complex combination of attributes
- Linq-to-sql query with translation from comma-separated of code to comma-separated of description
- GroupBy in LINQ and set property
- How can I sort distinct vals in LINQ (C#)?
- Any way for linq query to check against existing select?
- How can i get result from FirstOrDefault method with good performance
- How can I write generic query in asp .net mvc for 3 different tables in db context with LINQ?
- LINQ Join to find items NOT IN a list
- C# Entity Framework: Insert Child Entity and Update Parent, One Transaction
- Linq Sql Query Error for Get value
- How to get the string value of ExecuteCommand (or ExecuteQuery) from LINQ?
- LINQ Query Issues when trying to select from empty collection
- How to avoid "select n+1" pattern in Linq
- Generic filter class using LINQ
- Linq compare 2 object lists
- Gridview sorting in ASP.NET
- Using Max, Group By, Join and Where in Lambda Expression
- reversing text from input file using linq
- Using filters in linq expression tree
- Linq with DateTime.Parse
- Split IEnumerable in three parts: "above", "item", "below" with efficiency
- LINQ Help for a novice
- Best way to use same object for adding records LINQ C#
- LINQ lambda: how to combine two tables with no links