I have an IQueryable extension method:
public static void SomeExt<T>(this IQueryable<T> query, DbContext context) {...}
and I would like to know if there is some way to get DbContext from query so that DbContext argument could be removed leaving only:
public static void SomeExt<T>(this IQueryable<T> query) {...}
I have tried something like this Access DataContext behind IQueryable but its not working, getting zero fields.
Also there is way to get it from DbSet
Can you get the DbContext from a DbSet?
myDbSet.GetService<'ICurrentDbContext>().Context;
but that's not what I need. I want to get it from Query?
This is the query:
var q = context.Items.Where(a => a.StatusId = 1);
q.SomeExt(context);
vs
q.SomeExt();