Hi
I have below code & i want that if there is more than 1 record it should give message
TicketAnalysi objUpload = context.TicketAnalysis.Single(rec => rec.TicketID == Convert.ToInt32(hdfTicketId.Value));
Thanks
Hi
I have below code & i want that if there is more than 1 record it should give message
TicketAnalysi objUpload = context.TicketAnalysis.Single(rec => rec.TicketID == Convert.ToInt32(hdfTicketId.Value));
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Aravind GovindarajRank #430 · 5.8K reputationPosted Dec 6, 2022, 6:03 AM EST
Please find the code
var moreThanOneRecordExists = context.TicketAnalysis.Where(rec => rec.TicketID == Convert.ToInt32(hdfTicketId.Value)).Skip(1).Any();
Vishal JoshiRank #377 · 6.7K reputationPosted Dec 6, 2022, 8:03 AM EST
Hello
You can check count. please try below code.
if(context.TicketAnalysis.where(rec => rec.TicketID == (int)hdfTicketId.Value).count() == 1){ TicketAnalysi objUpload = context.TicketAnalysis.Single(rec => rec.TicketID == (int)hdfTicketId.Value); } else{ // Error Message }Thank you