views:

799

answers:

3
A: 

You may want to try Linq to Dataset:

LINQ to DataSet makes it easier and faster to query over data cached in a DataSet object. Specifically, LINQ to DataSet simplifies querying by enabling developers to write queries from the programming language itself, instead of by using a separate query language.

Keltex
Linq to Dataset indeed looks very interesting, however as far as I understand it doesn't combine the queries but rather processes the information client side? That would cause a major impact on performance. Or am I wrong about this and it does in fact combine the queries?
One idea I had was if it is possible to somehow inject sql in a Expression object, so that I could inject an Expression as exists (select 1 from SearchIndex ... ), but I couldn't find any way of doing this.
You're right. It handles the processes on the client side.
Keltex
A: 

I don't believe that there is a solution to this using LINQ. At least not that I have ever heard or found. LINQ breaks if the table structure changes and you have to recreate the DataModel every time.

If I am incorrect I am anxious to hear about it. :)

Jon Ownbey
+1  A: 

You're working outside of Linq to SQL's design, but I think it could be done if you really need to. Your best bet to explore is probably the XmlMappingSource that you can use in your context's constructor. I had some success with this when it came to handling table renaming on the fly.

In mapping XML, the actual column name on the database is the "Name" attribute of the column element whereas the class property is the "Member". If you change that in the XML it should map the eventual query appropriately.

Jacob Proffitt
I will have a look into this during the weekend, it does sound interesting indeed. I would really like to get this working through LINQ because of the maintainability of the code. Some extra background work would definately be worth the trouble.
I just finished a project that uses this technique and the confluence of Linq to XML (for altering the mapping xml) and Linq to SQL (for the data) made for a powerful combination.
Jacob Proffitt