How do I switch the table that is queried with linq-to-sql

Posted by Ian Ringrose on Stack Overflow See other posts from Stack Overflow or by Ian Ringrose
Published on 2010-04-28T15:57:26Z Indexed on 2010/04/28 16:53 UTC
Read the original article Hit count: 156

Filed under:
|

We have two tables with the same set of columns; depending on the “type” of object the value is stored in one of the two tables. I wish to use common code to access these two tables.

If I was using “raw sql” I could just use String.Format() to change the table name.

(Likewise for updates etc)


The two separate tables are needed as the data access patterns are very different for the common queries on the two tables and therefore different indexes are needed. “Views” and “instead of triggers” etc to make the tables look like a single table are not liked here. A lot of our customers use low end version of SqlServer so we cannot use partition tables.

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about .NET