tags:

views:

83

answers:

1

I'm trying to turn a method I have right now into a more "generic" method that returns a string. Right now, the method uses a statement like this:

var app = (from d in testContext.DAPPs
     where d.sserID == (Guid)user.ProviderUserKey
     select d).ToList();

I process the results of "app", add extra text etc. The piece that changes (that I need to make more "generic") is the table name (DAPPs). Is there a way I can do that, or, a better way to go around this all together?

A: 

You'll have to compose a Dynamic Linq Query.

There are a couple of ways to do this. Have a look at the following:

Dynamic Expressions in Linq to Sql
http://www.west-wind.com/Weblog/posts/143814.aspx

Using the LINQ Dynamic Query Library
http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

Robert Harvey