Click here to Skip to main content
16,022,752 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to get duplicate records while searching in asp.net with c#. The paging count is not working for Duplicate Account No check (x.EmployeeAccount.ToLower().Contains(txt_Srch_AccNo.Text.ToLower().Trim())

What I have tried:

My code is as below:
List<MDL_NONMOLSalaryDetail> pagingList = (from o in objDetailList
                                                       select o).Where(x => (x.EmployeeID.ToLower().Contains(txt_Srch_EmployeeName.Text.ToLower().Trim()) || txt_Srch_EmployeeName.Text.Trim() == "")
                                                                                 || (x.EmployeeName.ToLower().Contains(txt_Srch_EmployeeName.Text.ToLower().Trim()) || txt_Srch_EmployeeName.Text.Trim() == "")
                                                                                 || (x.EmployeeAccount.ToLower().Contains(txt_Srch_AccNo.Text.ToLower().Trim()) || txt_Srch_EmployeeName.Text.Trim() == "")
                                                                                 || (x.IsEdited.Equals(1) || txt_Srch_EmployeeName.Text.Trim() == "")
                                                                                 ).Skip(LeftStart).Take(TopRecords).ToList<MDL_NONMOLSalaryDetail>();
            int pageCount = (from o in objDetailList
                             select o).Where(x => (x.EmployeeID.ToLower().Contains(txt_Srch_EmployeeName.Text.ToLower().Trim()) || txt_Srch_EmployeeName.Text.Trim() == "")
                                                                                 || (x.EmployeeName.ToLower().Contains(txt_Srch_EmployeeName.Text.ToLower().Trim()) || txt_Srch_EmployeeName.Text.Trim() == "")
                                                                                 || (x.EmployeeAccount.ToLower().Contains(txt_Srch_AccNo.Text.ToLower().Trim()) || txt_Srch_EmployeeName.Text.Trim() == "")
                                                                                 || (x.IsEdited.Equals(1) || txt_Srch_EmployeeName.Text.Trim() == "")
                                                                                 ).Count();
Posted
Updated 29-Aug-17 7:03am
Comments
Graeme_Grant 29-Aug-17 1:01am    
"is not working" is not very meaningful. You are asking us to answer a question wearing a blindfold standing on one foot on a ball. How does it not work? Are you seeing any errors?

Also, the code is very difficult to read.

Click on the "Improve question" widget, clean up the code, and give a more meaningful description of what is expected, sample input, sample output, and what is actually happening with full exception information (if encountered). This is what is required to debug any code.

1 solution

To find duplicates, you have to do a Group by the column where the duplicate value is, then you have to do a
C#
.Count()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900