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
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://Support:1.0.11723
.42736/Support.AppGlobals> .EFMetadata
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://Support:1.0.11723
.42736/Support.AppGlobals/property:EFMetadata:String>  =
"res://*/LPP.csdl|res://*/LPP.ssdl|res://*/LPP.msl";
    AppGlobals
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://Support:1.0.11723
.42736/Support.AppGlobals> .CreateConnectionString
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://Support:1.0.11723
.42736/Support.AppGlobals/CreateConnectionString()> ();

 

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

        protected lehnerEntities
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LppDataAccess:1.0
.0.0/LppDataAccess.lehnerEntities>  _ctx
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LPP:1.0.0.0/LPP.v
mEisenbiegerei/_ctx:LppDataAccess.lehnerEntities> ;

 

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
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LppDataAccess:1.0
.0.0/LppDataAccess.LPP_LOGISTIK_EISENBIEGEN>  entity = new
LPP_LOGISTIK_EISENBIEGEN
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LppDataAccess:1.0
.0.0/LppDataAccess.LPP_LOGISTIK_EISENBIEGEN/.ctor()> ();
        this._ctx
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LPP:1.0.0.0/LPP.v
mEisenbiegerei/_ctx:LppDataAccess.lehnerEntities> .LPP_LOGISTIK_EISENBIEGEN
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LppDataAccess:1.0
.0.0/LppDataAccess.lehnerEntities/property:LPP_LOGISTIK_EISENBIEGEN:System.D
ata.Entity.DbSet%3cLppDataAccess.LPP_LOGISTIK_EISENBIEGEN%3e> .Add
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://EntityFramework:6
.0.0.0:b77a5c561934e089/System.Data.Entity.DbSet%3c%3e/Add(%3c!0%3e):%3c!0%3
e> (entity);
        this._ctx
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LPP:1.0.0.0/LPP.v
mEisenbiegerei/_ctx:LppDataAccess.lehnerEntities> .SaveChanges
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://EntityFramework:6
.0.0.0:b77a5c561934e089/System.Data.Entity.DbContext/SaveChanges():Int32>
();

 

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

    this._ctx
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LPP:1.0.0.0/LPP.v
mEisenbiegerei/_ctx:LppDataAccess.lehnerEntities>  = new lehnerEntities
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LppDataAccess:1.0
.0.0/LppDataAccess.lehnerEntities/.ctor(String)> (AppGlobals
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://Support:1.0.11723
.42736/Support.AppGlobals> .efSB
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://Support:1.0.11723
.42736/Support.AppGlobals/property:efSB:System.Data.EntityClient.EntityConne
ctionStringBuilder> .ConnectionString
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://System.Data:4.0.0
.0:b77a5c561934e089/System.Data.Common.DbConnectionStringBuilder/property:Co
nnectionString:String> );
    this._auftraege
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LPP:1.0.0.0/LPP.v
mEisenbiegerei/_auftraege:System.Linq.IQueryable%3cLppDataAccess.LPP_LOGISTI
K_EISENBIEGEN%3e>  = this._ctx
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LPP:1.0.0.0/LPP.v
mEisenbiegerei/_ctx:LppDataAccess.lehnerEntities> .GetOffeneEisenAuftraege
<http://127.0.0.1/roeder/dotnet/Default.aspx?Target=code://LppDataAccess:1.0
.0.0/LppDataAccess.lehnerEntities/GetOffeneEisenAuftraege():System.Linq.IQue
ryable%3cLppDataAccess.LPP_LOGISTIK_EISENBIEGEN%3e> ();

 

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&iu=/4140
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to