Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC Multiple AJAX Requests with Entity Framework causes error
    primarykey
    data
    text
    <p>I have two jqGrids that load data via an ajax POST call to my controller and each time I run the application, only one of the two POSTs executes successfully. Normally, if i hit refresh on the browser, both grids will load correctly. But consistently 1 of the 2 fail on first load of each view ( i have two views/pages that each have 2 jqGrids, "dashboard style"). In log4net logs the two requests have different threads and one always fails while the other succeeds but which one succeeds is random (probably first-come, first-serve)... Sometimes i get a null reference error when it tries to iterate through a resulting enumerable list of items, other times i get "The connection was not closed. The connection's current state is connecting."</p> <p>I have some suspicions of what might be the cause of this: EF lazy loading/proxies enabled, bad windsor configuration, automapper error that is not being thrown or shown in stack trace. But since i really have no clue, below is my setup in case it helps decipher this one. </p> <p><strong>Persistence</strong> [LifestyleSingleton] - This holds the EF4 datacontext (code-first) and a reference to EF4.3. There's a factory for creating the Context called GetContext() and this factory implements IDisposable.<br> <strong>Repo</strong> [LifestylePerWebRequest] - This holds repositories implementing the repository and specification pattern (http://huyrua.wordpress.com/2010/07/13/entity-framework-4-poco-repository-and-specification-pattern/).<br> <strong>Services</strong> [LifestylePerWebRequest] - Calls onto repo and applies bus logic, i.e. returns PagedList objects for UI paging.<br> <strong>Controllers</strong> [LifestyleTransient] - mvc controllers, make use of automapper for mapping to view model types.<br> <strong>MVC UI</strong> - I'm implementing Lib.Web.MVC which creates a strongly-typed wrapper for jqGrid. And from here, I use windsor container to do DI. </p> <p>UPDATE: I changed all components to register with LifestylePerThread and all of the errors seem to have been resolved with this. However, I do not understand why.. I'm new to DI so I'm sure i'm missing something. <strong>Could someone please explain why this has solved the issue?</strong> And what will this change do as far as scalability...? I figured I'd want the context factory along with the context itself to be registered as singleton's but that obviously wasn't correct. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload