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

  • Home
  • SEARCH
  • 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 5963345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:14:17+00:00 2026-05-22T19:14:17+00:00

I have a table named CLASS with the Fields **{BATCH, DEGREE, DEPT, SEM, SECTION,

  • 0

I have a table named CLASS with the Fields

    **{BATCH, DEGREE, DEPT, SEM, SECTION, GROUP }** 

I has the Following Records

Record1: { 2009 , B.E , CSE , 3Sem , ASec , 1Group }

Record2: { 2009 , B.E , CSE , 3Sem , ASec , 2Group }

Record3: { 2009 , B.E , ECE , 4Sem , ASec , 1Group }

Record4: { 2009 , B.E , ECE , 4Sem , ASec , 2Group }

I Need to Select Distinct Records Ignoring the GROUP and considering only the following

{BATCH, DEGREE, DEPT, SEM, SECTION }

So it should return me the following 2 Distinct Records

                  Record1: **{ 2009 , B.E , CSE , 3Sem , ASec , 1Group }** 

DistinctRecord: 1————————(OR)**

                  Record2: **{ 2009 , B.E , CSE , 3Sem , ASec , 2Group }**

—–(AND)

                  Record3: **{ 2009 , B.E , ECE , 4Sem , ASec , 1Group }**

DistinctRecord: 2————————(OR)

                  Record4: **{ 2009 , B.E , ECE , 4Sem , ASec , 2Group }**

Now i’m using the following LINQ Query

    public static object GetDistictClasses(IQueryable<Class> AllClasses)
    {
        return (from c in AllClasses
                group c by new { c.Batch, c.Degree_ID, c.Specialization_ID, c.CurrentSemester, c.Section_ID } into grp
                select new 
                {
                    grp.Key.Batch,
                    grp.Key.Degree_ID,
                    grp.Key.Specialization_ID,
                    grp.Key.CurrentSemester,
                    grp.Key.Section_ID
                }).Distinct();
    }

But it returns me a Ananymous Type, but i need the Actual Class Type

Could some one Help Me…
thank You..

Regrads
Pradeep

  • 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-22T19:14:17+00:00Added an answer on May 22, 2026 at 7:14 pm

    You can do the following:

    return
        from c in AllClasses
        group c by new
        {
            c.Batch, 
            c.Degree_ID, 
            c.Specialization_ID, 
            c.CurrentSemester, 
            c.Section_ID 
        } into grp
        select grp.First();
    

    This takes every first Class from the given group, thus returns a Entity object instead of a anonymous type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in my database called Task. Task has the following fields:
I have a database table (named Topics) which includes these fields : topicId name
i have a table Fields class 1 class 2 class 3 class 4 a1
I have two table Part and SubPart. Part table has general fields like id,
HI, I have Ling Table with MyObject. It has got fields: Id Number Name
Hi have a table named category which has two foreign keys to the table
I have this class called Table: class Table { public string Name { get
I have a table named Info of this schema: int objectId; int time; int
I have a table named categories, which contains ID(long), Name(varchar(50)), parentID(long), and shownByDefault(boolean) columns.
I have a table named visiting that looks like this: id | visitor_id |

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.