Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set "Query Hints" #214

Open
kam99 opened this issue Apr 15, 2013 · 5 comments
Open

Ability to set "Query Hints" #214

kam99 opened this issue Apr 15, 2013 · 5 comments

Comments

@kam99
Copy link

kam99 commented Apr 15, 2013

Hi, guys.

Does BLToolkit have an ability to gracefully set any of query hints/options, like that:
http://msdn.microsoft.com/en-us/library/ms181714.aspx ?

In particular i'm wondering how i can add "OPTION (RECOMPILE)" statement to the end of my query.

Thanks in advance.

@igor-tkachev
Copy link
Owner

@kam99
Copy link
Author

kam99 commented Apr 15, 2013

Looks optimistic! But not exactly what i'm looking for.

I can have "any complexity" level query, say this one:

var query = from e1 in Repository.All<DBEntity1>()
    join e2 in Repository.All<DBEntity2>() on e1.Entity1Id equals e2.Entity1Id
    where e2.SomeFieldId != null
    select new { e1.Entity1Id, e2.Entity2Id };

query.ToList();

and need get an output like that:

exec sp_executesql N'SELECT
    [e1].[Entity1Id],
    [e2].[Entity2Id]
FROM
    [DBEntity1] [e1]
        INNER JOIN [DBEntity2] [e2] ON [e2].[Entity1Id] = [e2].[Entity1Id]
WHERE
    [e2].[SomeFieldId] is not null
OPTION (RECOMPILE)'

@igor-tkachev
Copy link
Owner

I think that the only way to implement it is to give you access to SQL generation process. Somehow. No idea how.

@NetTecture
Copy link

Create a way to inject hints into the process via a Extension method. WithHint (TableHint.NoLocking) for example.

Providers then can decide to honor them or not.

I have similar items - I do a ton of queries in SQL Server "WITH (READCOMMITTED)" (does not LEAVE locks).

@kam99
Copy link
Author

kam99 commented Jun 25, 2013

2 NetTecture:

As it was pointed here #214 (comment)
there is a way to implement Table Hint already.

It works fine (at least for me) - for one of my needs i put WITH (NOLOCK) TableExpression attribute on a generic method that gets a table, and can easily reuse it through all my code. Similar way you can apply any Table Hint.

What not supported and what this ticket about is - entire Query (not just a "single" table) Hint/Option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants