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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:52:50+00:00 2026-05-26T09:52:50+00:00

i looked a bit around stackoverflow to find an answer for my question. All

  • 0

i looked a bit around stackoverflow to find an answer for my question.
All what i found is this: Get Last ID From The table [ Entity Framework ]

This is exactly what i need.. but there is no answer for this question.. seems that the guy who asked the question didnt explain why he needs it.

I am coding a ticket system for my company.

Now if someone creats a ticket i want him not to type in the Ticket ID (Ticket #) by himself.. i want a textbox which is Enabled = false. It should automatically be filled with the new Ticket ID (it must be the last Ticket ID + 1).

This is the reason why i am looking for the last id of my entity.

i tryed out this:

var ticketNrQuery = (from tn in kdVerwaltung.Ticket
                     orderby tn.Ticket_ID
                     select tn).Last();
textBoxTicketNr.Text = (ticketNrQuery.Ticket_ID + 1).ToString();

in this sample i get an unsupported exception (what the hell).

Any solutions for my problem?

  • 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-26T09:52:51+00:00Added an answer on May 26, 2026 at 9:52 am

    You can use MAX() since it can be translated to SQL:

    var maxTicketId = kdVerwaltung.Ticket.Max(x => x.Ticket_ID) + 1;
    

    That will be translated into the following query:

    SELECT MAX([t0].Ticket_ID) as [value] FROM [dbo].[YourTable] AS [t0]
    

    You should profile this if you’re going to use it in production. Using MAX can be pretty slow if you have a lot of rows.

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

Sidebar

Related Questions

I've looked around a bit and I can't seem to find the answer to
I've looked around a bit and can't seem to find an answer. I just
I've looked around a bit and have found no definitive answer on how to
I've looked around a bit, but can't seem to find the answer I'm looking
[I'm not sure if this question has been asked, though I've looked around a
I've looked around a bit and I can't come up with an answer on
Bit of an Objective-C rookie, I've looked around for an answer but haven't been
I've looked around for a bit now at other suggestions relating to this, but
I've got a bit of a tricky question I couldn't find the answer to.
I've looked around on here quite a bit for an answer to my problem

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.