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 9021863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:21:28+00:00 2026-06-16T05:21:28+00:00

I am fairly new to using Linq which is turning out a bit tricky

  • 0

I am fairly new to using Linq which is turning out a bit tricky for me on filtering the best datasource from a c# datatable. I need to perform the following filtering to a datatable. The background behind the data is that it is a set of records which contain independent redundancies from different datasources for the purpose of failsafe. In case one datasource had become corrupted at some point, a secondary or third datasource would become the primary source for that event thread.

Original Data (for example):
signintable:

source  First       Last
d1      John        Smith
d1      John        Smith
d3      John        Smith
d1      Jane        Doe
d2      Jane        Doe
d3      Richard     Miles
d3      Richard     Miles
d1      Richard     Miles

I would like to add two columns to this: a count of unique members of groups by(firstname, lastname and datasource), and a uniqueRecordGroupnumber based on distinct group (firstname, lastname, datasource) but ordered by whichever datasource for that particular first name last name has the most records, to the least.

source  First   Last    Count   UniqueRecordGroup
d1      John    Smith   2       1
d1      John    Smith   2       1
d3      John    Smith   1       2
d1      Jane    Doe     1       1
d2      Jane    Doe     1       2
d3      Richard Miles   2       1
d3      Richard Miles   2       1
d1      Richard Miles   1       2

Then I would finally filter out only the primary (unique record group 1) in order to eliminate the redundancies/ less reliable datasource for that particular record.

source  First   Last    Count   UniqueRecordGroup
d1      John    Smith   2       1
d1      John    Smith   2       1
d1      Jane    Doe     1       1
d3      Richard Miles   2       1
d3      Richard Miles   2       1

How are the above steps accomplished using Linq on a datatable (for example datatable signintable)?

Thank you.

  • 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-06-16T05:21:29+00:00Added an answer on June 16, 2026 at 5:21 am

    After now completing this application feature, I would not recommend trying to use Linq for this purpose. I found that there were not many resources and forums expressly for more involved Linq queries, whereas with Oracle, or SQL, plenty of forums and posts at least on the parts that were needed. So rather than add the feature in the c#/asp.net layer in Linq script, I added it in the database query layer.

    In Oracle, I accomplished the above by 4 steps:

    --1.  creating a derived table of unique instances of main data (a): (First, Last) and a count of instances in the main table:
    
    b As
    (select First, Last, source, COUNT(*) distinctpersoncount
    From a
    GROUP BY First, Last, source)
    
    --2.  Rank the fills from greatest to least.
    
    c As
    (select b.*, row_number() over(partition by  First, Last
    order by distinctpersoncount desc) as distinctpersonrowid
    from b
    
    
    --3.  combine the new distinctperson columns into a joined table with the original data a.
    
    d As
    (select a.*, c.distinctpersoncount, c.distinctpersonrowid
    from a
    left join c
    on
    .... (join conditions here)
    
    --4.  select all the data in d, filtering by distinctpersonrowid = 1 (the best source).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to Linq and struggling using dynamic where over a many to
If I need generate a fairly large dataset using LINQ and it may take
I am fairly new to .NET C# development and recently started using LINQ to
Alright, I need some advice and best practices from some Rails people. I'm fairly
I am fairly new to using SSRS and I would like to create a
I'm fairly new to using MSSQL and have run into a weird problem. Given
I'm fairly new to Azure and I'm using Blob storage to store some binary
I'm fairly new to C++ standard library and have been using standard library lists
I'm fairly new to database programming in WinForms, and have been using BindingSource, DataSet,
I'm fairly new to both Django and Python. This is my first time using

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.