Cannot apply indexing with [] to an expression of type ICollection

后端 未结 2 1412
醉话见心
醉话见心 2021-01-21 04:16

Can someone please provide code to fix this error?

\"Cannot apply indexing with [] to an expression of type \'ICollection\'

Essentially, I\'m trying to

相关标签:
2条回答
  • 2021-01-21 04:53

    ICollections are not ordered, so that cannot be indexed.

    Instead, you should use a separate ViewModel class with IList<T> property.

    0 讨论(0)
  • 2021-01-21 05:00

    Use IList

    public  class A
    {
       public int Name { get; set; }
       public virtual IList<B> Bs { get; set; }
    }
    
    0 讨论(0)
提交回复
热议问题