couchbaselabs / couchbaselabs/Linq2Couchbase

Named parameter / prepared query support

Open
#275 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
98
Forks
50
PR merge metrics
No merged PRs in 30d

Description

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:
```c#
var emailParam = new QueryParameter("test@example.com");
var data = userCtx.Query()
.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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.