DevArt DataContex slow creation

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Posts: 6
Joined: Tue 22 Nov 2011 20:57

DevArt DataContex slow creation

Post by MichaelH » Wed 01 Feb 2012 06:35

We done some profiling on our repositories (we are using linq for postgresql) and we discovered that the creation of DataContext it is really slow, it takes around 40ms to instantiate it. For our scenarios this is too slow, so, any ideas how this can be improved?

Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 02 Feb 2012 17:02

Could you please specify whether much time is needed to create a DataContext instance always or only the first time?

Generally, there are several possible ways to speed up creating a DataContext instance:
- Prepare mapping. If you are always connecting to the same server with your data contexts, you can share the mapping metadata between them. For example, if you use the attribute mapping, Entity Developer generates a static 'mappingSource' field of your DataContext descendant. This field is used to store the mapping metadata; it is initialized when creating the first instance of [YourDataContext].
- Prepare connection. If you use the default constructor of [YourDataContext] or pass the connection string to it, the connection object is created inside the DataContext constructor. You can, however, create the connection object before the data context, and pass the connection to the context constructor.
- Compile native images of Devart assemblies. To avoid performance loss caused by compiling native code for Devart assemblies, you can create native images of Devart assemblies on the machine where you are deploying your application to.

Please tell us if this helps.

Post Reply