Modifying LINQ To SQL command text(chriscavanagh.wordpress.com)

submitted by BobStroggBobStrogg(1033) 1 year, 2 months ago

Here’s a bit of code that’ll let you modify any command text LINQ To SQL generates before it hits the database. It’s always been possible to call DataContext.GetCommand and use modified SQL in a call to DataContext.Translate or DataContext.ExecuteQuery, but that’s pretty restrictive in the complexity of query you can use. Also, if LINQ To SQL decides it needs to batch multiple SELECT statements for the desired results, GetCommand can only give you the first one. The first thing to do is replace the IProvider implementation used by your DataContext. Unfortunately, DataContext’s Provider property is both private and read-only. Also, the IProvider interface itself is private. This is bad in every way, and we absolutely shouldn’t try to hack our way through that… but we will.

add a comment |category: |Views: 40

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story