Hi,
How can I automatically read custom data filter parameter value from AbpSession just like TenantId (as mentioned <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Data-Filters">http://www.aspnetboilerplate.com/Pages/ ... ta-Filters</a>)? I don't want to use CurrentUnitOfWork.SetFilterParameter for every action.
Thanks, Payman
4 Answer(s)
-
0
Hi,
Please see this example. <a class="postlink" href="https://gist.github.com/hikalkan/67469e05475c2d18cb88">https://gist.github.com/hikalkan/67469e05475c2d18cb88</a>
-
0
Hi,
That did not meet my requirements. Suppose you have a dropdown listing years and you also have some entities implementing IHasYear (which has an int property Year). Then, by changing the value in dropdown, a Year is saved into session. Now, my question is, how to filter all subsequent queries for all controller actions based on the selected year without having to use CurrentUnitOfWork in each action. Please note that the Year can be changed after login. Would you please help?
Thanks, Payman
-
0
Hi,
Override the Initialize method of your dbContext, call base's Initialize first and then add your parameter value like this. <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.EntityFramework/EntityFramework/AbpDbContext.cs#L182">https://github.com/aspnetboilerplate/as ... xt.cs#L182</a>
-
0
Thank you so much!