args.Filter

Can someone just point me in the right direction for documentation on how to affect args.Filter?

Following line is what I am trying to research..

var result = await AccelerateDataService.GetStores(new Query { Top = args.Top, Skip = args.Skip, Filter = args.Filter, OrderBy = args.OrderBy });

Switching from Radzen Studio to Radzen Blazor Studio is giving me some challenges...BUT I am determined to learn it!

Not sure if I understand what you are trying to achieve.

In Radzen Studio, it was simple to invoke a method to call a table in a database, then you could apply a filter to it.

I am currently trying to learn how to accomplish the same tasks from Radzen Studio in Radzen Blazor Studio.

Here is an example. I have extended the AspNetUsers table to include a column called AccountID which is an integer

I have a table called Stores that has the AccountID, StoreID and StoreName

I have a dropdown that lists the StoreNames and I want to only show Stores associated with a specific account.

This was easily accomplished in Radzen Studio, and I can see where it is called in Radzen Blazor Studio, but not sure how to change it. I believe it is the args.Filter portion of the above line. I know I need to use LoadData, but not sure where I can find documentation to help me with this.

I know you guys don't want to spend a ton of time teaching a person new to RBS how to do these simple tasks, so I just was hoping someone could point me to where I can read some documentation and apply it.

Thanks in advance!

You can still use Radzen Studio to make the query and check the generated filter code.

We plan to add similar capabilities (the query builder) to Radzen Blazor Studio very soon.

OK!!! I certainly overthought that one...thanks for the heads up on the query builder!!!

This is the generated code in Radzen Studio and it does not work in RBS...

(new Query() { Filter = $@"i => i.AccountID == @0", FilterParameters = new object[] { Security.User.AccountID }, Expand = "Account" })

I have tried it with and without the Expand Parameter.

I believe it is really looking for that args.Filter

Ok, so in RBS, tables are invoked using OData and is Radzen Studio they are not, so the filters are incompatible....

OData is used only in WebAssembly in both Radzen IDE and Radzen Blazor Studio. If you plan to copy code from Radzen IDE to RBS make sure the application types are same.

Ok, so I have switched to Blazor Server application. The filter operation is still not working for this case. I am trying to filter the values available in a drop down.

In Radzen Studio I have assigned each user an account number (this value is stored in AspNetUser table)

I have a table that has a list of stores assigned to each account number.

When the user logs in, he is presented a list of stores in the main layout that are filtered by the account number from AspNetUsers

I accomplished this by assigning the account number in the AspNetUser table to a global variable and then used that global variable to filter the Stores table for display in the dropdown. I then store the store number in a second global variable which is then used to filter all the other data in the application by account and store number.

Following is the generated filter from Radzen Studio that does not work in RBS. Also with this, your support for Global Variables is either different in RBS or not supported...not sure on that...but can you tell me how this query differs?

var conDataGetStoresResult0 = await ConData.GetStores(new Query() { Filter = $@"i => i.AccountId == @0", FilterParameters = new object[] { Globals.accountNumber }, Expand = "Account" });

There are no global variables in RBS templates by default however you can use the same generated code by Radzen IDE in RBS.

I'm stumped....All I am trying to do at this point is assign a column value in AspNetUsers to a parameter so that I can filter a dropdown in my main layout.

I can manually set the filter, but If I try to set my variable (accountID) to Security.User.AccountID (I extended AspNetUsers to include AccountID.

RBS lets me assign Security.User.AccountID to a RadzenNumeric but it when I try to assign it to predefined variable, it won't pass the value.

Here is the code

    protected System.Linq.IQueryable<Accelerate.Models.AccelerateData.Store> stores;
    protected int storeID = 0;
    protected long accountID =0;
    void SidebarToggleClick()
    {
        sidebarExpanded = !sidebarExpanded;
    }

    protected void ProfileMenuClick(RadzenProfileMenuItem args)
    {
        if (args.Value == "Logout")
        {
            Security.Logout();
        }
    }

    protected override async Task OnInitializedAsync()
    {
        long accountID = @Security.User.AccountID;
        stores = await AccelerateDataService.GetStores(new Query() { Filter = $@"i => i.AccountID == accountID"});
    }

I can replace accountID in the Filter with any number and it filters fine, but I can't get the value of Security.User.AccountID into a usable parameter...

How do I access and assign a value from Security.User?

This is just a string. If you want to use template string you should wrap your variable with {}.

That's fine...I just simplified the filter while I was testing. What I am trying to do is get a value from Security.User and assign it to a paramater.

In Radzen Studio I can assign a variable with a value like this
protected long accountID = 0;

then with that initialized, I can assign Security.User.AccountID to it, like this

accountID=Security.User.AccountID;

then the filter can use that accountID to filter by, this allows me to have a dropdown of stores that are assigned to that account number. The following line works fine in Radzen Studio

        var accelerateDataGetStoresResult = await AccelerateData.GetStores(new Query() { Filter = $@"i => i.AccountID == @0", FilterParameters = new object[] { accountID }, Expand = "Account" });

My only issue now is that I cannot get the value from Security.User.AccountID in to accountID

How do I assign Security.User.AccountID to accountID

I extended AspNetUsers to include AccountID

Have you tried to debug this code to see what is assigned as value?

Yes, it stays at the original value of 0 and does not pick up the correct value from AccountId in the AspNetUser table. Interestingly...if I put a Radzen Numeric box on the Layout next to the drop box and assign Security.User.AccountID it registers the value properly. It just won't work in the accountID paramenter...so RBS sees the AccountID correctly from AspNetUsers, I just can't assign it to anything...

All along I have been assuming its a filter issue, but it seems to be a value assignment issue.

Can you create a test application, extend the AspNetUsers to include a column called AccountID (long) and the try to assign Security.User.AccountID to a variable and see if it works for you?

Hey @daveg1466,

Can you clarify how exactly you extended AspNetUsers with this additional property and where the property value is populated. Your code that is assigning the from the property to variable is correct however most probably the property value itself is not.

I added an ApplicationUser.Custom.cs file and added the additional value as follows

public int64 AccountID {get; set;}

I then added a DbContext custom file

AccelerateDataContext.Custom.cs

adding the following code

using Accelerate.Models;
using Microsoft.EntityFrameworkCore;

namespace Accelerate.Data
{
public partial class AccelerateDataContext
{
partial void OnModelBuilding(ModelBuilder builder)
{
builder.Entity().ToTable("AspNetUsers");
}
}
}

then I used command prompt to go to the server directory and ran the dotnet command
got the succeeded message.

went back into visual studio and removed the extraneous entries from the migration file.

Checked my database and it was updated correctly with AccountID and a data type if bigint (which I believe translates to long in C#)

I then went into RBS and added a field call accountID with a value of zero and a type of long.

I then tried to assign Security.User.AccountID to it and that is where I am stuck.

Still unclear where the value of this field is populated. I’m not sure also what is the issue you are reporting. Please debug carefully your application.