Page 1 of 1

select new' clause of LINQ queries doesn't work on 2.5 relea

Posted: Tue 31 May 2011 02:39
by grace
I encountered select new' clause of LINQ queries problem which was reported fixed on 1.0.43 04-Nov-10. it seems to be still there on new release.


this is error message i'm getting

Code: Select all

[NullReferenceException: Object reference not set to an instance of an object.]
   Devart.Data.Linq.Provider.g.a(bg A_0) +1476
   Devart.Data.Linq.Provider.h.a(bg A_0) +646
   Devart.Data.Linq.Provider.g.a(SqlExpression A_0) +847
   Devart.Data.Linq.Provider.g.a(SqlExpression A_0, Boolean A_1) +109
   Devart.Data.Linq.Provider.n.a(IDataServices A_0, SqlExpression A_1, Boolean A_2) +156
   Devart.Data.Linq.Provider.n.a(Type A_0, SqlExpression A_1, IDataServices A_2) +162
   Devart.Data.Linq.Provider.CompiledQuery.GetReaderFactory(List`1 elementInstanceTypes, IDataServices services, SqlNode query) +473
   Devart.Data.Linq.Provider.CompiledQuery..ctor(QueryInfo queryInfo, IDataServices services, Boolean isQueryObjectByKey, Object queryObjectKey) +137
   Devart.Data.Linq.Provider.DataProvider.BuildQuery(Expression query) +313
   Devart.Data.Linq.Provider.DataProvider.Devart.Data.Linq.Provider.IProvider.Compile(Expression query) +46
   Devart.Data.Linq.DataQuery`1.i() +31
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +7663302

Posted: Tue 31 May 2011 09:29
by StanislavK
Thank you for the report. This is a known problem, it may occur when selecting objects of non-entity but not anonymous type in LINQ queries.

We have already fixed this issue, the fix will be available in the nearest build.

Posted: Wed 15 Jun 2011 06:11
by grace
I've tested 2.50.24 relase.
the problem is still there. but the problem comes when I hit the refresh button this time.

Code: Select all

Unable to cast object of type 'Devart.Data.Linq.Mapping.as' to type 'Devart.Data.Linq.Mapping.MetaTypeBase'. 

Exception Details: System.InvalidCastException: Unable to cast object of type 'Devart.Data.Linq.Mapping.as' to type 'Devart.Data.Linq.Mapping.MetaTypeBase'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[InvalidCastException: Unable to cast object of type 'Devart.Data.Linq.Mapping.as' to type 'Devart.Data.Linq.Mapping.MetaTypeBase'.]
   Devart.Data.Linq.Provider.Query.af.a(MetaType A_0, ITable A_1, IList`1 A_2) +215
   Devart.Data.Linq.t.a(MetaDataMember A_0, au A_1, List`1 A_2) +167
   Devart.Data.Linq.Provider.l.SetLinks(TEntity obj, MetaType objMetaType, Object keySource, IList`1 linkMembers, t services, Dictionary`2 queryLoadWith, Dictionary`2 nextLoadWiths, Boolean deferredLoadingEnabled) +655
   lambda_method(ExecutionScope , b ) +2368
   Devart.Data.Linq.Provider.ObjectReader`1.g() +27

 
If I remove Select= "new (...)" from the DbLinqDataSource, the error doesn't come up.

Posted: Wed 15 Jun 2011 17:10
by StanislavK
Could you please describe the issue in more details? For example, please specify the DBMS you are working with and the query with which this issue occurs.

We couldn't reproduce the issue in simple situations like

Code: Select all

var list = (from dept in context.Depts select new MyDept { Dname = dept.Dname, Loc = dept.Loc }).ToList();
The 'MyDept' class here has two public properties 'Dname' and 'Loc', the 'Dept' entity class is generated for the following table:

Code: Select all

CREATE TABLE DEPT (
  DEPTNO NUMBER(4) CONSTRAINT PK_DEPT PRIMARY KEY,
  DNAME VARCHAR2(14) ,
  LOC VARCHAR2(13)
);

Posted: Thu 16 Jun 2011 03:33
by grace
I just tested more.

Error only comes with postback I guess.

This is when it really happens.






Course1 is associated data from another table by foreign key.
this causes the error.

Posted: Thu 16 Jun 2011 12:25
by StanislavK
We have reproduced this issue. We will inform you as soon as it is fixed.

Does this issue been addressed?

Posted: Mon 30 Jan 2012 17:46
by Breno999
Hi!

Sorry to bump this, but does this issue been addressed or not? I´ve been seeing this issue frequently in my code.

I had to change a lot of lines to go around this.

Thanks in advance!

Posted: Wed 01 Feb 2012 16:53
by StanislavK
We are working on this issue, but cannot provide any timeframe for it at the moment. We will post here when any new information is available.