帕特里克,感谢有关正确问题的建议!
编辑1:
我有三张关于多对多关系的表.像这样:

GoodEntity:
public partial class GoodEntity
{
public GoodEntity()
{
this.GoodsAndProviders = new HashSet<GoodAndProviderEntity>();
}
public int id { get; set; }
public string name { get; set; }
public string description { get; set; }
public decimal cost { get; set; }
public Nullable<decimal> price { get; set; }
public virtual ICollection<GoodAndProviderEntity> GoodsAndProviders { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
ProviderEntity:
public partial class ProviderEntity
{
public ProviderEntity()
{
this.GoodsAndProviders = new HashSet<GoodAndProviderEntity>();
}
public int id { get; …Run Code Online (Sandbox Code Playgroud) 我想从特定位置迭代项目集合。假设我们想从中心开始迭代数组的整个右侧部分:
int startFrom = arr.length / 2;
for (int i = startFrom; i < arr.length; i++)
{
String.format("Index %d value %s", i, arr[i]);
}
Run Code Online (Sandbox Code Playgroud)
在迭代过程中跟踪真实的索引和值非常重要。作为示例,您将实现就地排序算法
我尝试使用 drop().withIndexes() 来执行此操作,但看起来 drop() 创建了一个新集合,并且我丢失了有关真实索引的信息。如果我们创建一个变量并计算适当的索引,则可以手动修复它
val startFrom = inputData.size / 2
for ((i, item) in inputData.drop(startFrom).withIndex()){
val fixedIndex = i + startFrom
println("Index $i, fixed index $fixedIndex value $item")
}
Run Code Online (Sandbox Code Playgroud)
这个解决方案有效,但我希望有一些东西可以帮助避免引入单独的固定索引变量并手动处理这个问题。