Dropdown multi many to many

Hi,
lets say i have 3 tables: "A", "AB" and "B" with many to many FK's
A = "A.Id", "A.Name"
AB = "AB.Id", "AB.AId", "AB.BId"
B = "B.Id", "B.Role"

now i want to create an Add Page for "A" with a dropdown multiselect from "B".
dropdown should show all Roles from B and the selected B.Id's and the A.Id should be bind together in "AB.AId" and "AB.BId".

How can i achieve that?

I hope its clear what i mean :slight_smile:

Thanks for help!
Thomas

Hi @Thomas,

Do you mean something as the example I am describing here?

Hi @korchev ,

I tried implementing your solution here but cannot do the map at step 3...

|Error|CS1061|'IQueryable' does not contain a definition for 'map' and no accessible extension method 'map' accepting a first argument of type 'IQueryable' could be found (are you missing a using directive or an assembly reference?)

Without the map I am getting issues with casting the FormRef icollection (from getForm used as the drop down data) to the FormRef iqueryable.

What is map and why don't I have it?

@simon, I think that example is based on Angular and the map is a javascript command. Not sure if blazor version is available.

Thanks @mumfie I could see it was angular but incorrect assumed that it also applied for blazor. Any ideas on how to do the same in Blazor??

Hi @simon. Have used that sample but not in blazer.
@korchev or @enchev will likely be able to advise.

IQueryable indeed does not have a map method. The equivalent is Select. You can find plenty of information online.

I am using a datasource method to pull in the table then assigning this using set property with a linq select. This produces a <long?> which does not work with the multiselect dropdown value being <long>. How can I force the two to work together?.

@simon,
Have you tried assigning it using the Value property?
e.g.

Hi,
I have tried each of the assignments below (not at the same time):
IEnumerable<long> outlist;
var getResult = await db.Gettable(new Query() { Filter = $@"i => i.fkid == (""{args.id}"")" });
outlist = getResult.Select(i => i.fkid);
outlist = (IEnumerable<long>)getResult.Select(i => i.fkid);
outlist = (IEnumerable<long>)getResult.Where(i => i != null).Select(i => i.fkid);
outlist = (IEnumerable<long>)getResult.Where(i => i != null).Select(i => i.fkid!);

table.fkid is of type Int64? and is the foreign key for reftable.refid which is Int64

It works in outlist is <long?> but then the dropdon cannot use this as the value