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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:47:31+00:00 2026-06-14T04:47:31+00:00

Entity Frame 5.0 question. I am new to Entity Frame, basically I have a

  • 0

Entity Frame 5.0 question.

I am new to Entity Frame, basically I have a table “MyPIN”.

[Table("MyPIN")]
public class BatchPINDetail
{
    public BatchPINDetail();
    public int Number { get; set; }

I want to run a query

int x = the biggest Number FROM MyPIN 

The correspond codes are:

public class InContext : DbContext
{
    public InContext();
    public InContext(string connectionString);

    public DbSet<BatchDetail> BatchDetailsRecords { get; set; }

}

Question 1: I am not sure how to retrieve it.

Question 2: After I get the value, I want to reassign the value, say Number += 1; I need to write it to DB.

Thanks for 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-06-14T04:47:32+00:00Added an answer on June 14, 2026 at 4:47 am
    InContext inContext = new InContext(cnStr);
    // get first biggest item
    BatchPINDetail entity = inContext.BatchDetailsRecords
                                     .OrderByDescending(x => x.Number)
                                     .First();
    // get all biggest items
    BatchPINDetail entities = inContext.BatchDetailsRecords
                                     .Where(x => x.Number == x.Max(x => x.Number))
                                     .ToArray();
    
    // and if you just want to get biggest number. 
    // but note that if you just change `num` nothing will happen.
    int num = inContext.BatchDetailsRecords.Max(x => x.Number);
    
    entity.Number += 1;
    inContext.SaveChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

@Entity @Table(name=Product_info) public class Product { private int ProductIndex; private int priority; private Date
I'm new to entity frame work code first. I have simple class called Cat
@Entity public class TestClass implements Serializable{ private Integer id; private Set<String> mySet; @Id @GeneratedValue
I have an NHibernate entity that looks like this: public class Offender { public
I very new to Linq and Entity frame work, i have problem with my
@Entity public class Blobx { private String name; private BlobKey blobKey; @Id @GeneratedValue(strategy =
I want to have following type of query in entity frame work SELECT c2.*
I am using Entity Frame work as an ORM and i want to have
Let just say I have the following data models: public class Account { public
I am a newbie for Entity frame work..I have to setup our project solution..and

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.