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

前端 未结 18 2303
孤街浪徒
孤街浪徒 2020-11-22 01:40

I have this query and I get the error in this function:

var accounts = from account in context.Accounts
               from guranteer in account.Gurantors
           


        
18条回答
  •  不知归路
    2020-11-22 02:17

    As a side-note...this can also happen when there is a problem with (internal) data-mapping from SQL Objects.

    For instance...

    I created a SQL Scalar Function that accidentally returned a VARCHAR...and then...used it to generate a column in a VIEW. The VIEW was correctly mapped in the DbContext...so Linq was calling it just fine. However, the Entity expected DateTime? and the VIEW was returning String.

    Which ODDLY throws...

    "There is already an open DataReader associated with this Command which must be closed first"

    It was hard to figure out...but after I corrected the return parameters...all was well

提交回复
热议问题