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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:30:13+00:00 2026-05-20T07:30:13+00:00

I have an EF model from which I select a sub-set of data to

  • 0

I have an EF model from which I select a sub-set of data to present in ASP.NET. When I am presenting this output I loop through the returned objects. I would like to know when I am presenting the object with the highest value (to format it differently).

ObjectTable
Category  Item Value
X         A    1.0
X         B    14.0
X         C    9.0
Y         D    18.0

I can return the items I want to view with:

var obj = from o in ObjectTable where Category=="X" select o;

I want to know that B has the highest value.

I am very flexible with how this happens I just haven’t been able to come up with a sensible solution. Should I modify the LINQ statement to add a LET statement creating an obj.IsMax variable and if o.Value==o.Max make it TRUE and all other objects as FALSE, if so how? This route seems like it would be expensive?

Or could I extend the EF Model with a partial class and somehow calculate whether the model value is equal to the max value of the returned objects?

Or something completely different?

  • 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-20T07:30:13+00:00Added an answer on May 20, 2026 at 7:30 am
    var obj  = (ObjectTable.Where(o => o.Category == "Y"));
    var anonymousObjList = obj.Select(o => new {o, IsMax = (o.Value == obj.Max(x => x.Value))});
    

    And looping thru anonymousObjList

    foreach(var obj in anonymousObjList)
    {
        var actualObject = obj.o;
        var isMax = obj.IsMax;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this in my BlogRepository public IQueryable<Subnus.MVC.Data.Model.Post> GetPosts() { var query = from
I have a data model in Doctrine/symfony. I have a 'Course' which has many
I have a simple ADO.NET Entity Framework 4.0 model (edmx) which defines database tables
I have a data model in which I have an Item that can belong
Here's the problem I'm having in my ASP.NET web-form project. I have Datalist which
I have two models, Article and Post that both inherit from a base model
I have a model being populated by my data layer and then I have
I have a model Foo which have a ForeignKey to the User model. Later,
Let's say I have a model like this class Foo(db.Model): id = db.StringProperty() bar
Let's say I have this model named Product with a field named brand .

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.