Type Conversion error in LINQ

Absogue

New Member
I am trying to convert stored Proc to LINQ using only LinqPad. I have following code in Linq\[code\]var myVar = (from st in Student where st.name == "abcd" select st).Take(10);if (myVar.Any()){ // some statements}else{ myVar = (from emp in Employee where emp.name == "abcd" select emp).Take(10); }\[/code\]But it is giving following error at select line in else block\[code\]Cannot implicitly convert type 'System.Linq.IQueryable<AnonymousType#1>' to 'System.Linq.IQueryable<AnonymousType#2>'\[/code\]Can anyone know what is happening? How to solve it? How can I explicitly convert type in Linq?Columns in both table are different. And I am not using any framework like entity framework etc. I just have the db of application and I am trying to convert all Stored Proc's into LINQ. And in the Stored Proc both values are caught in same variable and that's why I need them in same variable. So can it is possible in this scenario?
 
Top