In your code,
var datasource = new NORTHWNDEntities().Categories.ToList();
var datasource1 = new NORTHWNDEntities().Customers.ToList();
var datasource2 = new NORTHWNDEntities().Orders.ToList();
If these three lines are correct and datasource, datasource1 and datasource2 are IEnumerable then your code shouldn't produce any error. Are you getting the error in this line?
ViewData["datasource"] = Datasource;
Does
new NORTHWNDEntities().Categories.ToList();
returns a
IEnumerable
, then your code shouldn't produce errors.
And to concat three IEnumberables, the following code works(a modification of code in Soln 1):
List<int> a = new List<int>();
a.Add(1);
a.Add(2);
List<int> b = new List<int>();
b.Add(3);
b.Add(4);
List<int> c = new List<int>();
c.Add(5);
c.Add(6);
IEnumerable<int> a2 = a.Cast<int>();
IEnumerable<int> b2 = b.Cast<int>();
IEnumerable<int> c2 = c.Cast<int>();
IEnumerable<int> concat = a2.Concat(b2).Concat(c2);
And also, don't use
var
always. I'm not against
var
, but you should know the type of the object before you use it.