Linq WCF and variable join
-
Thursday, April 17, 2008 3:03 PM
In a WCF method I would like to have a simple query, like the following
var dc = new DataContext();
var elements = (from pg in dc.PackageGroups
join bv in query on pg.Id equals bv.PackageGroupId
select new LookupListItem { Id = pg.Id, Description = pg.Description }).Distinct();
return elements.ToList();
My problem is that the query variable I would like to pass into this WCF method from the front-end, but IQueryable<> is not serializable, so I can't do that. What I'm trying to accomplish is be able to call a method and have some table PackageGroup in this case joined to some other table (this other table I do not know and only the front-end will know what the name of this table is).
All Replies
-
Thursday, April 17, 2008 6:49 PM
I ended up solving this problem with the following type of code, where the baseValuesMatrix variable is a string that I pass into the procedure.
var t = Type.GetType(baseValuesMatrix); if (t.GetInterface("IPackageGroup") != null){
var dc = new OceanSpray.DataContext(); var bvm = dc.GetTable(t).Cast<IPackageGroup>();

