That is what I though as well, but I can't seem to use Security.User.Id in a filter. It generates an empty table.
I have tried the same filter in both radzen studio and RBS and it works fine in raden studio but not at all in RBS.
I did a test on a blank slate application.
The only table I added to the database was called employees, with the following columns
EmployeeID (primary key)
FirstName
LastName
EmpUserID (nvarchar(450) just like the Id field in the AspNetUsers table)
I Generated a new Blazor Server application in RBS
I Added the database and did not modify any settings accept for setting the formfield to flat
I ran the application and it ran fine.
I Stopped the application and added Security (just basic, no registration or password reset)
I ran the application and logged in as admin...still fine
I them modified the Add ApplicationUser page to add a new employee record and copy the user.Id to the employee table. Following is the code.
[Inject]
public FilterTestDataService FilterTestDataService { get; set; }
protected IEnumerable<FilterTest.Models.ApplicationRole> roles;
protected FilterTest.Models.ApplicationUser user;
protected FilterTest.Models.FilterTestData.Employee employee;
protected IEnumerable<string> userRoles = Enumerable.Empty<string>();
protected string error;
protected bool errorVisible;
[Inject]
protected SecurityService Security { get; set; }
protected override async Task OnInitializedAsync()
{
user = new FilterTest.Models.ApplicationUser();
employee = new FilterTest.Models.FilterTestData.Employee();
roles = await Security.GetRoles();
}
protected async Task FormSubmit(FilterTest.Models.ApplicationUser user)
{
try
{
user.Roles = roles.Where(role => userRoles.Contains(role.Id)).ToList();
await Security.CreateUser(user);
employee.EmpUserID = user.Id;
await FilterTestDataService.CreateEmployee(employee);
DialogService.Close(null);
}
catch (Exception ex)
{
errorVisible = true;
error = ex.Message;
}
}
I saved and ran the application and created two users.
The user.Id was successfully added to both employee records.
I then modified the Employee page (not the Add or Edit) with the following code (The ONLY change I made)
protected override async Task OnInitializedAsync()
{
employees = await FilterTestDataService.GetEmployees(new Query() { Filter = $@"i => i.EmpUserID == @0", FilterParameters = new object[] { Security.User.Id }});
}
I ran the application logging in as each user and checked the Employee page and no records could be displayed.
I did the exact same procedure in Radzen Studio and it worked exactly as intended.
The only reason I wanted to detail this experiment is to see if the way filtering for Security.User.Id is different between the two applications. It just isn't evident to me.
Not looking for deep dive support on this, just want to know if my code is correct.
Thanks for looking