LinqConnect Metro

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
floatingleaf
Posts: 6
Joined: Sat 16 Mar 2013 16:18

LinqConnect Metro

Post by floatingleaf » Sat 16 Mar 2013 16:23

Hi All

I was wondering the best approach to handle the context in a windows 8 app?
I am uses a reportistory pattern for data access.

Do I

1/ Create a public static variable to the context and all data access uses that single one?

or

2/ Instantiate a connection each time and close when completed?


Ade

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LinqConnect Metro

Post by MariiaI » Mon 18 Mar 2013 13:41

We don't recommend to use static instance of the DataContext, due to the fact that this one instance will accumulate obsolete data (after the data has been received, it is cached and when working for a time with one DataContext, the data in the database may change while the data in the cache will be old).
DataContext is a lightweight object, and it is recommended to use new DataContext for each unit of work instead of keeping it for a long time.

Post Reply