Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6780055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:27:38+00:00 2026-05-26T16:27:38+00:00

I’m trying to run a Linq query on a datatable to produce a result,

  • 0

I’m trying to run a Linq query on a datatable to produce a result, filtered by User and then into Date. I’m following an example of the Group By – Nested on the Linq 101 example page here.

However I wasn’t able to get it working. I’m getting a couple of errors. So I was hoping that someone would give me a hand creating the query, or at least help me get on the right track.

This is the current non-working code that I put together from the example.

var results =
                 from d in dataTableResults.AsEnumerable()
                 select new 
                    { 
                        d["DIMS User"],
                        DateGroup =
                            from o in d["Entry Date"]
                            group o by o["Entry Date"] into dg
                            select new { "Entry Date" = dg.Key, "DIMS user" = dg}
                    };

This is my DataTable Structure: (Date/Time are seperate from ShortDateToString/ShortTimetoString parse)

LogData.Columns.Add("System User", typeof(string));
LogData.Columns.Add("Host Name", typeof(string));
LogData.Columns.Add("DIMS User", typeof(string));
LogData.Columns.Add("Entry Details", typeof(string));
LogData.Columns.Add("Asset Name", typeof(string));
LogData.Columns.Add("Entry Date", typeof(string));
LogData.Columns.Add("Entry Time", typeof(string));

The errors I’m receiving are:

1) Invalid anonymous type member declarator. Anonymous type members
must be declared with a member assignment, simple name or member
access.

2) Could not find an implementation of the query pattern for source
type ‘object’. ‘GroupBy’ not found.

Lastly, Thanks for reading my post and Thanks in Advance for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:27:39+00:00Added an answer on May 26, 2026 at 4:27 pm

    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
                                               };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.