Inconsistent state of Linq provider

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
dilbert
Posts: 68
Joined: Tue 28 Apr 2009 10:11

Inconsistent state of Linq provider

Post by dilbert » Tue 24 Apr 2012 10:42

Generally, our web works properly several days. However, sometime linq gets into a state that each query throws exception even if new datacontext is used for each query. I'm not sure what is the cause and it's unable to reproduce it on development environment.

This is example of an exception (but it could be completely different):

Code: Select all

MESSAGE: Invalid datatype: datetime
SOURCE: Devart.Data.MySql.Linq
TARGETSITE: Devart.Data.MySql.Linq.Provider.MySqlProviderType a(System.String, Boolean)
STACKTRACE:    at Devart.Data.MySql.Linq.Provider.a.a(String A_0, Boolean A_1)
   at Devart.Data.MySql.Linq.Provider.b.a.a(String A_0)
   at Devart.Data.Linq.Provider.DataSourceInfo.TypeSystemProvider.GetProviderType(String typeName)
   at Devart.Data.Linq.Provider.Query.SqlFactory.Default(MetaDataMember member)
   at Devart.Data.Linq.Provider.Query.SqlFactory.Member(SqlExpression expr, MetaDataMember member)
   at Devart.Data.Linq.Provider.Query.ac.a(SqlExpression A_0, MetaType A_1, List`1& A_2, List`1& A_3, SqlExpression& A_4, IList`1 A_5)
   at Devart.Data.Linq.Provider.Query.ac.b(SqlExpression A_0, MetaType A_1, List`1& A_2, List`1& A_3, SqlExpression& A_4, IList`1 A_5)
   at Devart.Data.Linq.Provider.Query.ac.a(s A_0, IList`1 A_1)
   at Devart.Data.Linq.Provider.Query.ac.a(MetaType A_0, ITable A_1, IList`1 A_2)
   at Devart.Data.Linq.Provider.Query.r.a(ITable A_0)
   at Devart.Data.Linq.Provider.Query.r.j(Expression A_0)
   at Devart.Data.Linq.Provider.Query.r.a(Expression A_0, LambdaExpression A_1)
   at Devart.Data.Linq.Provider.Query.r.b(MethodCallExpression A_0)
   at Devart.Data.Linq.Provider.Query.r.j(Expression A_0)
   at Devart.Data.Linq.Provider.Query.r.b(Expression A_0, LambdaExpression A_1, Boolean A_2)
   at Devart.Data.Linq.Provider.Query.r.b(MethodCallExpression A_0)
   at Devart.Data.Linq.Provider.Query.r.j(Expression A_0)
   at Devart.Data.Linq.Provider.Query.r.i(Expression A_0)
   at Devart.Data.Linq.Provider.DataProvider.BuildQuery(Expression query)
   at Devart.Data.Linq.Provider.DataProvider.Devart.Data.Linq.Provider.IProvider.Execute(Expression query)
   at Devart.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
   at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
....
Only solution is to restart application.

My question is if there is an option to reset variables of linq provider - especially static etc. in this situation to avoid application crash?

We are using latest version of Mysql dotConnect - 6.80.341.

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

Post by StanislavK » Thu 26 Apr 2012 14:24

Could you please specify sample queries with which such problems occur and the tables being queried? If you are getting some other exceptions with different stack traces, please specify their messages and stack traces too.

As for resetting the LinqConnect parameters, the DataProvider instance is re-created each time you create a new DataContext object. The static components being shared among different instances of DataContext are:
1) The compiled query cache:
http://www.devart.com/linqconnect/docs/ ... eries.html
you can try disabling it by removing the following line in the code generated for your DataContext type:

Code: Select all

public static CompiledQueryCache compiledQueryCache = CompiledQueryCache.RegisterDataContext(typeof([YourDataContext]));
2) The mapping source (this can be the problem's reason only if you are using the attribute mapping for your DataContext). If you do use the attribute mapping, the mapping source is created once and saved in a static field of [YourDataContext] type. Here is the corresponding generated code:

Code: Select all

private static MappingSource mappingSource = new AttributeMappingSource();
You can, e.g., modify the code so that a static method that returns a new AttributeMappingSource object is used instead of this field.

Post Reply