Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In c#, I am using a query:
SELECT format( Trans.Dt,"MM/dd/yyyy HH:mm:ss") , Trans.InOut , Trans.EmpID FROM Trans where( format((Trans.DT),'Short Date') in('8/25/2014')) order by Trans.EmpID ASC;

from which I am creating two separate list

List 1:

var objList = from element in list where element.InOut == "0" && element.EmpID == empIds[j].ToString() orderby element.DateInOut ascending select element;

List<employeedata> listquery0 = objList.ToList<employeedata>();

List 2:

var objList1 = from element in list where element.InOut == "1" && element.EmpID == empIds[j].ToString() orderby element.DateInOut ascending select element;

List<employeedata> listquery1 = objList1.ToList<employeedata>();
Now,
I want to create a new list that contains the output of two lists.


Thanks in Advance!!
Posted
Comments
johannesnestler 8-Sep-14 9:58am    
If the resulting lists are of the same type just concat the lists. But why not Change your query so it gives back the "correct" list straight away?
var objList1 = from element in list where (element.InOut == "0" || element.InOut == "1") && element.EmpID == empIds[j].ToString() orderby element.DateInOut ascending select element;

1 solution

If you absolutely cannot get everything in one query, the way to make a compound list is very easy.

From your code it looks like you are using the same data type, so....

C#
listquery.AddRange(listquery1);
 
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