Question

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?

1
1
10/7/2018 11:08:44 AM

Accepted Answer

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.

-1
10/7/2018 12:08:38 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow