Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: Unable to cast object of type 'System.Collections.Generic.List`1[CustomerManager.Model.Customer]' to type 'CustomerManager.Model.Customer'. Pin
Dave Kreskowiak25-Jun-14 3:51
mveDave Kreskowiak25-Jun-14 3:51 
GeneralRe: Unable to cast object of type 'System.Collections.Generic.List`1[CustomerManager.Model.Customer]' to type 'CustomerManager.Model.Customer'. Pin
uglyeyes25-Jun-14 3:57
uglyeyes25-Jun-14 3:57 
GeneralRe: Unable to cast object of type 'System.Collections.Generic.List`1[CustomerManager.Model.Customer]' to type 'CustomerManager.Model.Customer'. Pin
Nathan Minier25-Jun-14 4:07
professionalNathan Minier25-Jun-14 4:07 
QuestionRe: Unable to cast object of type 'System.Collections.Generic.List`1[CustomerManager.Model.Customer]' to type 'CustomerManager.Model.Customer'. Pin
Nathan Minier25-Jun-14 3:59
professionalNathan Minier25-Jun-14 3:59 
AnswerRe: Unable to cast object of type 'System.Collections.Generic.List`1[CustomerManager.Model.Customer]' to type 'CustomerManager.Model.Customer'. Pin
uglyeyes25-Jun-14 15:51
uglyeyes25-Jun-14 15:51 
QuestionHow to extract a propertybag or complex object send from VB6 through MSMQ in C# Pin
SnailsWayne24-Jun-14 22:15
SnailsWayne24-Jun-14 22:15 
AnswerRe: How to extract a propertybag or complex object send from VB6 through MSMQ in C# Pin
Dave Kreskowiak25-Jun-14 3:02
mveDave Kreskowiak25-Jun-14 3:02 
GeneralRe: How to extract a propertybag or complex object send from VB6 through MSMQ in C# Pin
SnailsWayne25-Jun-14 14:59
SnailsWayne25-Jun-14 14:59 
GeneralRe: How to extract a propertybag or complex object send from VB6 through MSMQ in C# Pin
Dave Kreskowiak25-Jun-14 17:26
mveDave Kreskowiak25-Jun-14 17:26 
GeneralRe: How to extract a propertybag or complex object send from VB6 through MSMQ in C# Pin
SnailsWayne25-Jun-14 21:33
SnailsWayne25-Jun-14 21:33 
AnswerRe: How to extract a propertybag or complex object send from VB6 through MSMQ in C# Pin
Bernhard Hiller25-Jun-14 20:29
Bernhard Hiller25-Jun-14 20:29 
GeneralRe: How to extract a propertybag or complex object send from VB6 through MSMQ in C# Pin
SnailsWayne25-Jun-14 21:33
SnailsWayne25-Jun-14 21:33 
QuestionWant place code logic in class using Inno setup Pin
Ashfaque Hussain24-Jun-14 20:31
Ashfaque Hussain24-Jun-14 20:31 
AnswerRe: Want place code logic in class using Inno setup PinPopular
Pete O'Hanlon24-Jun-14 20:40
mvePete O'Hanlon24-Jun-14 20:40 
GeneralRe: Want place code logic in class using Inno setup Pin
Ashfaque Hussain24-Jun-14 22:00
Ashfaque Hussain24-Jun-14 22:00 
QuestionCreate Microsoft Excel in C# Pin
Jassim Rahma24-Jun-14 20:22
Jassim Rahma24-Jun-14 20:22 
AnswerRe: Create Microsoft Excel in C# Pin
Kornfeld Eliyahu Peter24-Jun-14 20:29
professionalKornfeld Eliyahu Peter24-Jun-14 20:29 
AnswerRe: Create Microsoft Excel in C# Pin
Richard Deeming25-Jun-14 1:32
mveRichard Deeming25-Jun-14 1:32 
SuggestionRe: Create Microsoft Excel in C# Pin
LucasRLS25-Jun-14 1:57
LucasRLS25-Jun-14 1:57 
AnswerRe: Create Microsoft Excel in C# Pin
Nguyen.H.H.Dang25-Jun-14 18:45
professionalNguyen.H.H.Dang25-Jun-14 18:45 
QuestionDbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 3:25
professionalNathan Minier24-Jun-14 3:25 
AnswerRe: DbContext recreate with cache clear Pin
Dave Kreskowiak24-Jun-14 5:04
mveDave Kreskowiak24-Jun-14 5:04 
GeneralRe: DbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 5:52
professionalNathan Minier24-Jun-14 5:52 
GeneralRe: DbContext recreate with cache clear Pin
Dave Kreskowiak24-Jun-14 6:00
mveDave Kreskowiak24-Jun-14 6:00 
GeneralRe: DbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 6:22
professionalNathan Minier24-Jun-14 6:22 
According to the MSDN[^] documentation the cache is created on first instantiation and tied to the AppDomain. To an extent that is my issue, because I cannot reset that cache. I can inject new IModels in at runtime and they are not included in new instances of the DbContext until the application is restarted, at which point OnModelCreating is called again. This implies to me that the cache is functioning as intended. The population of the context model is happening just once, as is efficient, but I would like to bump it when an extension is added to re-build the context model again.

Fortunately the DbContext doesn't actually execute any SQL until an IQuryable has a terminal method run on it, such as .Single, .First, or .toList; I agree that it would be mind-numbingly inefficient if it did. Instead, after the initial context creation it automatically caches the specific implementation of DbContext so that it holds the ORM but not the table data. Future instances come from this cache instead of being generated at runtime. It's pretty slick, honestly, and does perform nicely. My only complaint is the completely crazy statements it generates for Table-Per-Type implementations (which model polymorphism much better than Table-Per-Hierarchy or Table-Per-Class) and, of course, this cache refresh obnoxiousness.

I think I understand the communication breakdown here. I'm not interested in the data, I want to call that per request in accordance with the UnitOfWork pattern. I want to find that DbContext model cache and refresh it when a new extension is loaded.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.