Skip to content

Named parameter / prepared query support #275

@olee

Description

@olee

Hi, would it be possible to integrate support for named / positional parameters, mainly to boost performance by utilizing query plan caching / prepared queries?

I could imagine something like this:

var emailParam = new QueryParameter("[email protected]");
var data = userCtx.Query<User>()
    .Where(x => x.Email == emailParam.Value)
    .Select(u => new
    {
        FirstName = u.FirstName,
        LastName = u.LastName,
    })
    .UsePreparedQuery("my-prepared-query") // maybe name can be optional? 
                                            // it might be possible to generate a unique name by hashing the expression tree or something like that?
    .ToList();

The QueryParameter class could be detected in the expression visitors and it would automatically generate a named parameter at its position and add its value to the final query with AddNamedParameter.

Additionally the UsePreparedQuery extension would mark the generated query to be registered as a prepared query with couchbase to improve performance for future executions.

I'm quite new to couchbase but have some knowledge regarding linq expression trees, so I hope this proposal makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions