How to efficiently combine a direct SQL query and Linq To SQL query? Linq To SQL doesn’t support XQuery. So I have to combine the results of a SQL with XQuery and column based Linq To SQL?
Any pointers is appreciated. Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Chris Cavanagh has a couple blog posts that provide options for leveraging XQuery in conjunction with LINQ to SQL.
SQL Server XQuery with LINQ to SQL provides the framework for a solution that would involve embedding the XQuery into user-defined functions, which can be accessed from LINQ to SQL
Modifying LINQ to SQL command text and Modifying LINQ to SQL command text again provide a way to extend LINQ to SQL’s query execution, by manipulating the generated command text to support XQuery constructs.
The end result is you can actually use XQuery directly from your DataContext, by writing code that looks like:
(However, if you find that you need to do this kind of thing a lot, there’s a chance you will be better off with a document database like MongoDB or RavenDB, which are meant for working with hierarchical/post-relational models)
As a side note about XQuery and SQL in general, you will get varying degrees of support in different versions. Specifically, the XQuery support in SQL 2005 is a limited subset of the support in later versions.