Re: [Firebird-net-provider] Entity Framework: Best practices to work in a multiuser environment

2016-03-26 Thread Jiří Činčura
> Indeed. It's EF poor design, that they try to rework in EF core.
> Still there are plenty of workarounds for this. For example attaching
> entities only by ids.

Attaching by ID? It's still attaching...

> DbContext is supposed to be used in request-response scenario (web
> sites, for example), where context object is short-living object.

Quite opposite. Short-living context is recommended in request-response
scenarios. If you can keep the instance - like WPF, WinForms, etc. - the
benefit of having the context to track what you're doing is great help.

The context class itself was not designed to be used in any scenario in
particular. It should work and works in all range of options .NET
ecosystem offers. In fact, even just the disconnected scenario has at
least like 3 options to tackle it.

-- 
Mgr. Jiří Činčura
Independent IT Specialist

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351=/4140
___
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider


Re: [Firebird-net-provider] Entity Framework: Best practices to work in a multiuser environment

2016-03-26 Thread Геннадий Забула
> That doesn't make any sense. If I dispose context after query then I
can't update the entities without attaching them to new context. Waste
of resources.

Indeed. It's EF poor design, that they try to rework in EF core.
Still there are plenty of workarounds for this. For example attaching
entities only by ids.

DbContext is supposed to be used in request-response scenario (web
sites, for example), where context object is short-living object.


On 26 March 2016 at 11:20, Jiří Činčura  wrote:
>> > d) Do I need to dispose the the context on closing the window?
>> Not only on that. you should create and dispose context for every
>> action you do with a database: insert, delete, update, query etc.
>
> That doesn't make any sense. If I dispose context after query then I
> can't update the entities without attaching them to new context. Waste
> of resources.
>
>> > 3.   As long the user does not explicit reload the data I am working 
>> > in a connected mode
>> You don't have to be always connected for any reason.
>
> True. But for fat client type applications this is then way easier than
> disconnected scenarios.
>
> --
> Mgr. Jiří Činčura
> Independent IT Specialist
>
> --
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785351=/4140
> ___
> Firebird-net-provider mailing list
> Firebird-net-provider@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351=/4140
___
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider


Re: [Firebird-net-provider] Entity Framework: Best practices to work in a multiuser environment

2016-03-26 Thread Jiří Činčura
> > d) Do I need to dispose the the context on closing the window?
> Not only on that. you should create and dispose context for every
> action you do with a database: insert, delete, update, query etc.

That doesn't make any sense. If I dispose context after query then I
can't update the entities without attaching them to new context. Waste
of resources.

> > 3.   As long the user does not explicit reload the data I am working in 
> > a connected mode
> You don't have to be always connected for any reason.

True. But for fat client type applications this is then way easier than
disconnected scenarios.

-- 
Mgr. Jiří Činčura
Independent IT Specialist

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351=/4140
___
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider


Re: [Firebird-net-provider] Entity Framework: Best practices to work in a multiuser environment

2016-03-25 Thread Геннадий Забула
EF context is implementation of unit-of-work pattern, it is not
repository pattern.

> d) Do I need to dispose the the context on closing the window?
Not only on that. you should create and dispose context for every
action you do with a database: insert, delete, update, query etc.

> 3.   As long the user does not explicit reload the data I am working in a 
> connected mode
You don't have to be always connected for any reason.

On 25 March 2016 at 09:18, Jiří Činčura  wrote:
>> a) Is the method described above considered as good practice?
>
> From what you've written, yes.
>
>> b) Basically it is a connected Context until the user refreshes the data.
>> In
>> this case the context is recreated.
>
> No problem with that.
>
>> c) In order to manage multiuser environment, do I need to work generally
>> with disconnected entities?
>
> No, you don't have to.
>
>> d) Do I need to dispose the the context on closing the window?
>
> Yes, you should.
>
> --
> Mgr. Jiří Činčura
> Independent IT Specialist
>
> --
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785351=/4140
> ___
> Firebird-net-provider mailing list
> Firebird-net-provider@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351=/4140
___
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider


Re: [Firebird-net-provider] Entity Framework: Best practices to work in a multiuser environment

2016-03-25 Thread Jiří Činčura
> a) Is the method described above considered as good practice?

From what you've written, yes.

> b) Basically it is a connected Context until the user refreshes the data.
> In
> this case the context is recreated.

No problem with that.

> c) In order to manage multiuser environment, do I need to work generally
> with disconnected entities?

No, you don't have to.
 
> d) Do I need to dispose the the context on closing the window?

Yes, you should.

-- 
Mgr. Jiří Činčura
Independent IT Specialist

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351=/4140
___
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider


[Firebird-net-provider] Entity Framework: Best practices to work in a multiuser environment

2016-03-25 Thread Nikolaus Kern
Hello all,

 

I am using EF 6.0 with Firebird 4.10 and have same questions about best
practices. It is an WPF/MVVM application that runs in a multiuser
environment.

 

1.   There is a static class to create the connection string

AppGlobals
 .EFMetadata
  =
"res://*/LPP.csdl|res://*/LPP.ssdl|res://*/LPP.msl";
AppGlobals
 .CreateConnectionString
 ();

 

2.   I am using long living efcontext as protected variable in the
ViewModel to read the data

protected lehnerEntities
  _ctx
 ;

 

3.   As long the user does not explicit reload the data I am working in
a connected mode

 

4.   Inserts, updates and deletes use the same context

LPP_LOGISTIK_EISENBIEGEN
  entity = new
LPP_LOGISTIK_EISENBIEGEN
 ();
this._ctx
 .LPP_LOGISTIK_EISENBIEGEN
 .Add
 (entity);
this._ctx
 .SaveChanges

();

 

5. When the user wants to refresh (F5) I instanciate the context again and
use it as before

this._ctx
  = new lehnerEntities
 (AppGlobals
 .efSB
 .ConnectionString
 );
this._auftraege
  = this._ctx
 .GetOffeneEisenAuftraege
 ();

 

Questions:

a) Is the method described above considered as good practice?

b) Basically it is a connected Context until the user refreshes the data. In
this case the context is recreated.

c) In order to manage multiuser environment, do I need to work generally
with disconnected entities?

d) Do I need to dispose the the context on closing the window?

 

Thanks

 

Niko

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351=/4140___
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider