Click here to Skip to main content
15,867,835 members
Home / Discussions / C#
   

C#

 
GeneralRe: Windows 7 Files Explorer - New Folder In Tree Pin
fakir4459-Sep-12 5:14
fakir4459-Sep-12 5:14 
GeneralRe: Windows 7 Files Explorer - New Folder In Tree Pin
Eddy Vluggen9-Sep-12 5:35
professionalEddy Vluggen9-Sep-12 5:35 
GeneralRe: Windows 7 Files Explorer - New Folder In Tree Pin
fakir4459-Sep-12 9:24
fakir4459-Sep-12 9:24 
QuestionIs it OK to implement Repository Pattern with Singleton in C# and EntityFramework ? Pin
Mohammad Dayyan8-Sep-12 21:52
Mohammad Dayyan8-Sep-12 21:52 
QuestionRe: Is it OK to implement Repository Pattern with Singleton in C# and EntityFramework ? Pin
Eddy Vluggen9-Sep-12 0:26
professionalEddy Vluggen9-Sep-12 0:26 
AnswerRe: Is it OK to implement Repository Pattern with Singleton in C# and EntityFramework ? Pin
Mohammad Dayyan9-Sep-12 0:52
Mohammad Dayyan9-Sep-12 0:52 
AnswerRe: Is it OK to implement Repository Pattern with Singleton in C# and EntityFramework ? Pin
Eddy Vluggen9-Sep-12 1:12
professionalEddy Vluggen9-Sep-12 1:12 
AnswerRe: Is it OK to implement Repository Pattern with Singleton in C# and EntityFramework ? Pin
jschell9-Sep-12 4:24
jschell9-Sep-12 4:24 
Mohammad Dayyan wrote:
<layer>Repository Pattern



Repository Pattern is just applying a new name to an old idiom - a database layer. And yes you should have a database layer.


Mohammad Dayyan wrote:
with Singleton to have the same DbContext in each entity's instance?


Is is ok to use a Singleton? I doubt it.


(from your other post...)


otherwise, for each entity we have to write Update, Delete, Insert,
Reposit


Not sure what you think you are doing but you are going to need to do that regardless.


Mohammad Dayyan wrote:
<layer>Static class is an instance for all, and it has the same position in RAM of system.
but Singleton has a static field and we can have different instances of our class, but we prevent coupling


As stated that is basically all wrong.

First classes, not data, all exist as a single instance (again the class and not the class instance) in memory excluding AppDomains.

Second in modern OSes the OS moves applications, everything including data, code and OS management stuff associated with application around all the time including moving it to the hard drive. So it can never be said to be in one place in the RAM.

Third class instances (not the class this time) are managed by the C# heap and it can move them around in memory. So it won't even be in the same place in virtual memory.

Fourth, although a Singleton has a rigid definition the conceptual idea of a 'single' instance can take many forms, including implementing access via a static class.

Fifth, none of that has anything to do with coupling.


I suspect that you should at least first attempt to write the Repository code. AFTER you complete that then you can consider the following
1. Are threads involved?
2. Is there any point to using a singleton?

If the answer to the first is no and the answer to the second is yes then you can use a singleton.
GeneralRe: Is it OK to implement Repository Pattern with Singleton in C# and EntityFramework ? Pin
Mohammad Dayyan27-Sep-12 2:26
Mohammad Dayyan27-Sep-12 2:26 
QuestionC# scheduled jobs Pin
dcof8-Sep-12 16:46
dcof8-Sep-12 16:46 
AnswerRe: C# scheduled jobs Pin
PIEBALDconsult8-Sep-12 19:08
mvePIEBALDconsult8-Sep-12 19:08 
AnswerRe: C# scheduled jobs Pin
jschell9-Sep-12 4:27
jschell9-Sep-12 4:27 
QuestionC# directory folder levels Pin
dcof8-Sep-12 16:45
dcof8-Sep-12 16:45 
AnswerRe: C# directory folder levels Pin
Eddy Vluggen9-Sep-12 0:23
professionalEddy Vluggen9-Sep-12 0:23 
AnswerRe: C# directory folder levels Pin
jschell9-Sep-12 4:30
jschell9-Sep-12 4:30 
GeneralRe: C# directory folder levels Pin
dcof9-Sep-12 8:49
dcof9-Sep-12 8:49 
GeneralRe: C# directory folder levels Pin
Pete O'Hanlon9-Sep-12 10:05
subeditorPete O'Hanlon9-Sep-12 10:05 
GeneralRe: C# directory folder levels Pin
dcof9-Sep-12 10:30
dcof9-Sep-12 10:30 
GeneralRe: C# directory folder levels Pin
Pete O'Hanlon9-Sep-12 10:35
subeditorPete O'Hanlon9-Sep-12 10:35 
AnswerRe: C# directory folder levels Pin
jschell10-Sep-12 8:55
jschell10-Sep-12 8:55 
QuestionC# linq not update table correctly Pin
classy_dog8-Sep-12 15:19
classy_dog8-Sep-12 15:19 
QuestionC# with several proejct folders using linq to sql Pin
classy_dog8-Sep-12 15:14
classy_dog8-Sep-12 15:14 
AnswerRe: C# with several proejct folders using linq to sql Pin
Dave Kreskowiak8-Sep-12 16:58
mveDave Kreskowiak8-Sep-12 16:58 
GeneralRe: C# with several proejct folders using linq to sql Pin
classy_dog9-Sep-12 8:51
classy_dog9-Sep-12 8:51 
GeneralRe: C# with several proejct folders using linq to sql Pin
Dave Kreskowiak9-Sep-12 13:27
mveDave Kreskowiak9-Sep-12 13:27 

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.