Entity Framework: There is already an open DataReader associated with this Command which must be closed first

前端 未结 5 1919
太阳男子
太阳男子 2021-02-06 02:58

This question is related to this:

My repository method has this code:

 public IEnumerable GetApplicationPositionHistor         


        
5条回答
  •  萌比男神i
    2021-02-06 03:23

    Generally do not use EF object in view, but create a POCO object for the view model and map the query result on the view model. EF do not execute the query in your repository method because the query are not executed at definition time but only when you try to access the data. In your view you are using the same query many time and this is not correct.

    If you want to access the list of object returned by your repository method, use toList

提交回复
热议问题