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

[QUESTION] Generic searching on ILiteQueryable<T> #2457

Open
ssteiner opened this issue Mar 22, 2024 · 0 comments
Open

[QUESTION] Generic searching on ILiteQueryable<T> #2457

ssteiner opened this issue Mar 22, 2024 · 0 comments
Labels

Comments

@ssteiner
Copy link

I would like to perform a generic search like this:

var table = context.GetCollection<T>();
var query = table.Query();
if (typeof(INamedItem).IsAssignableFrom(typeof(T)))
{
    var myItems = query as ILiteQueryable<INamedItems>;
	// now run a filter on the ILiteQueryable<INamedItem>
	query = myItems as ILiteQueryable<T>;
}

But, myItems is always null. I've been using the same approach with EFCore (where I work with IQueryable<T> instead of ILiteQueryable<T>) - what do I need to do do get a properly typed ILiteQueryable so I can use Linq syntax to run queries rather than to have to write BSonExpressions?

@ssteiner ssteiner changed the title [QUESTION] Generic searching [QUESTION] Generic searching on ILiteQueryable<T> Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant