Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4062054
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:33:01+00:00 2026-05-20T15:33:01+00:00

Our development stumbled onto a major roadblock in terms of Linq to Sql and

  • 0

Our development stumbled onto a major roadblock in terms of Linq to Sql and Sql 2005+ Xml Fields. We have an Xml blob field containing fields…

<Profile name-first="Terry" name-last="Aney" [...more]/>

To leverage LINQ to SQL, we created a UDF in SQL and added that to our DataContext and call that (loosely based on LINQ to SQL (Part 6 – Retrieving Data Using Stored Procedures)
). However, when we use these functions, the XML Indexing by SQL is rendered useless. A filtered and ordered query against a population of 14,000 rows and it times out with the default 30 second CommandTimeout. But if we take the command text (sniffed by SQL Profiler) and swap out the UDF with direct XQuery, the query takes less than a second (obviously what we want). I’ve seen similar questions about Xml Fields (i.e. this question) but the common answer is to use UDFs – but we’ve proven those are inefficient if used extensively.

We are hoping there is some low level point where we can grab the command text and swap out the UDF with proper XQuery syntax (via a RegEx). Not ideal, but it’s the only solution we can see feasible. We are open to anything – command text translation, CLR integration with SQL, etc.

In certain situations, we could do this already. For instance if we always have an IQueryable where T is not an anonymous and/or complex/nested type we could call GetCommandText and then call DataContext.Translate(). However, for anonymous/complex types and/or scalar queries, we aren’t seeing an place to hook into.

Any suggestions are greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:33:02+00:00Added an answer on May 20, 2026 at 3:33 pm

    FYI, my coworker has ‘solved’ the problem. A bit ‘evil’ but doing the job for us. http://chriscavanagh.wordpress.com/2011/03/12/manipulating-linq-to-sql-command-text/

    So basically, now that we can modify, we created some ‘placeholder’ functions in our L2S DataContext that are obviously UDFs. But we intercept command, and swap them out for proper XQuery value/exists() syntax to make sure it is as performant as possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a common problem of moving our development SQL 2005 database onto shared
My team (4 people) have just reached a major milestone in our development, putting
Our development team is planning to upgrade from visual studio 2005 to visual studio
weWithin our development environment we have VS2010 installed on my computer along with Expresison
We have upgraded our development SAP system from ECC6 SPS3 to ECC6 SPS5 .
We have 15 projects in our development environment. Some are test projects, most are
We have recently introduced version control in Subversion in our development cycle, and a
On our development server, we have a database server with collation: COLLATE SQL_Latin1_General_CP1_CI_AS .
On our development server, we have a bunch of shell script wrappers for Java
I've been doing some research into finally automating our Development builds and still have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.