I use an entity structure (ef) and get the following error:
"The result of the query cannot be listed several times.".
I have a repository class that contains an ef data context. Then I have a controller class (not to be confused with MVC controllers) that contains the storage instance. So far so good ... I have a search method on the controller that should return a RadComboBoxItemData array that is used to populate the Telerik RadComboBox control.
public RadComboBoxItemData[] Search(int id, string searchText) { var query = context.Search(id, searchText); List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(); foreach (var item in query) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Text = "";
When I debug my code, I can get into the foreach loop, but then I get the error message:
An exception of type 'System.InvalidOperationException' occurred in System.Data.Entity.dll, but was not processed in the user code
Additional information: The result of a query cannot be listed more than once.
My object uses the import function of an existing stored procedure.
// EF repository method calling the function imported method on the data context. public IEnumerable<SearchItem> Search(int id, string searchText) { return this.entityContext.Search(id, searchText); }
The import Search function calls the stored preface to return the SearchItem collection.
I have the feeling that the foreach loop cannot iterate because of something with ef.
Halcyon Apr 19 2018-11-21T00: 00Z
source share