tags:

views:

236

answers:

3

We create tables in runtime. They have the same schema layout as tables that exist in our DBML but with an alternate name. We want to set the table names in runtime in our use of Linq to Sql.

Using wrapper classes on the Metadata as outlined in https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4233721&SiteID=1 works great for the updates, deletes and inserts.

Does anyone know how we can get the read of the alternate table to work?

A: 

You need to new up your LINQ expression at run-time via System.Linq.Expressions

Paul Betts
+1  A: 

You need to use an external mapping file. Populate the xml with the names of your table at runtime. This over-rides the attribute based mapping.

David B
A: 

Adam, did you ever figure out the reason behind selects not pulling the right table name? I've been working on this for a while and can't seem to figure it out. I could try an external xml file (just to test it out because it won't work with my situation) but how is that any different from specifying the customattributemappingsource as the mappingsource to the datacontext?
I think this is either the provider or the table that is not returning the correct expression. shurg