如何在具有多对多关系的视觉设计器中创建连接
How to create joins in visual designer with many to many relationship
所以我有 3 种数据类型。一个区可以代表多个县,一个县可以有多个区。
县
县名(字符串)
区
地区名称(字符串)
县(多个 Select Dropbox)
候选人
名称(字符串)
地区名称(字符串)
我要模板生成
A 县
-->1区
--->约翰
--->比尔
--> 2区
----->苏珊
B县
-->1区
---->约翰
----->比尔
--> 3区
----->杰克
----->简
有没有办法使用可视化编辑器和/或 Razor 来实现为此所需的多对多关系?
谢谢!
迈克尔
所以这就是我所做的......我最终提取了完整的查询,然后在嵌套循环中使用了值过滤器。
如果我们可以简单地将参数从 razor 传递到 sqldatasource,那将是非常好的,但由于这似乎不可用,我们得到这样的东西:
@using ToSic.Eav.DataSources
var allCounties = App.Query["Counties"]["Counties"];
var allHouseDistricts = App.Query["Districts"]["MDHouseDistricts"];
@foreach (var thisCounty in AsDynamic(allCounties.List)) {
@thisCounty.CountyName
@{
var someHouseDistricts = CreateSource<ValueFilter>(allHouseDistricts);
someHouseDistricts.Attribute = "DistrictCounties";
someHouseDistricts.Value = thisCounty.CountyName;
someHouseDistricts.Operator = "contains";
}
@foreach (var thisHouseDistict in AsDynamic(someHouseDistricts.List)) {
@thisHouseDistict.HouseDistrictName
}
}
这是我们构建的页面:
https://www.mdrealtor.org/Legislative/Resources/Home-Ballot
所以我有 3 种数据类型。一个区可以代表多个县,一个县可以有多个区。
县
县名(字符串)
区
地区名称(字符串) 县(多个 Select Dropbox)
候选人
名称(字符串) 地区名称(字符串)
我要模板生成
A 县
-->1区
--->约翰
--->比尔
--> 2区
----->苏珊
B县
-->1区
---->约翰
----->比尔
--> 3区
----->杰克
----->简
有没有办法使用可视化编辑器和/或 Razor 来实现为此所需的多对多关系?
谢谢!
迈克尔
所以这就是我所做的......我最终提取了完整的查询,然后在嵌套循环中使用了值过滤器。
如果我们可以简单地将参数从 razor 传递到 sqldatasource,那将是非常好的,但由于这似乎不可用,我们得到这样的东西:
@using ToSic.Eav.DataSources
var allCounties = App.Query["Counties"]["Counties"];
var allHouseDistricts = App.Query["Districts"]["MDHouseDistricts"];
@foreach (var thisCounty in AsDynamic(allCounties.List)) {
@thisCounty.CountyName
@{
var someHouseDistricts = CreateSource<ValueFilter>(allHouseDistricts);
someHouseDistricts.Attribute = "DistrictCounties";
someHouseDistricts.Value = thisCounty.CountyName;
someHouseDistricts.Operator = "contains";
}
@foreach (var thisHouseDistict in AsDynamic(someHouseDistricts.List)) {
@thisHouseDistict.HouseDistrictName
}
}
这是我们构建的页面: https://www.mdrealtor.org/Legislative/Resources/Home-Ballot