I want to use AbpSession
in my custom repository, but I can't get the instance. I want to extend DataFilter
on Entity Framework Core + .NET Core 2.1, what should i do?
I have already answered your question in comment. You have to declare a member of type IAbpSession
and initialise it with the value in the constructor. You can then use the UserId
, TenantId
..... properties accordingly.
public class MyClass : ITransientDependency
{
public IAbpSession AbpSession { get; set; }
public MyClass()
{
AbpSession = NullAbpSession.Instance;
}
public void MyMethod()
{
var currentUserId = AbpSession.UserId;
//...
}
}
You can refer the documentation here.