Error in Linq Query

Error in Linq Query

Postby dqrest » Wed 23 Sep 2015 07:37

Hi!
I have Devart.Data.Linq 4.4.697.0, Devart.Data.Oracle.Linq 4.4.697.0, Devart.Data.Oracle. 8.4.359.0 and use MS VS 2013 Ultimate, C#. Last week I upgraded versions of Devart.Data.Oracle from 6.50.228.0 to 8.4.359.0, Devart.Data.Linq from 3.0.5.0 to 4.4.697.0 and Devart.Data.Oracle.Linq from 3.0.5.0 to 4.4.697.0.

I faced to problems by executing a Linq queries in my WebSite which appeared in the following code:

Code: Select all
var data = (from c in All.SysFilterCriterions
            select
                new  MyCriterion()
                {
                    No = c.No,
                    FieldNo = c.FieldNo,
                    Caption = c.Caption,
                    IsLocalField = c.FieldNo == c.E_FilterNo.BlockNo || c.E_FieldNo_51.BlockNo == c.E_FilterNo.BlockNo
                })
            .ToList();


Class "MyCriterion" is declared in class "Core_Pages_FlatHandbookFilter" which is a WebPage and is derivated from Page.

Code: Select all
public partial class Core_Pages_FlatHandbookFilter : Page
{
   ..........
   public void func()
   {
        // here is linq query code
   }
    public class MyCriterion
    {
   public long No;
        public long? FieldNo;
        public string Caption;
        public bool IsLocalField;
    }
}



And when I launch website I have the following error:

'Devart.Data.Linq.Engine.ObjectReader`1[TN.Core.MainModule+MyCriterion]' cannot be converted to type 'System.Collections.Generic.IEnumerator`1[Core_Pages_FlatHandbookFilter+MyCriterion]'."

Note when I add the class "Criterion" to the class "TN.Core.MainModule" and use the class "Criterion" instead of the class "MyCriterion" in the mentioned linq query, the error is disappeared.
I'd like to say that I elimated all namepsaces System.Data.Linq.Mapping and System.Data.Linq from my WebSite. At last, I represent the class "TN.Core.MainModule"

Code: Select all
namespace TN.Core
{
   public class MainModule : IHttpModule
   {
             public void Dispose()
            {
                   // .....
            }
            public void Init(HttpApplication context)
       {   
                  // ....
            }
           

            public class Criterion
            {
                public long No;
                public long? FieldNo;
                public string Caption;
                public bool IsLocalField;
            }
        }
}


What happaneds?
dqrest
 
Posts: 7
Joined: Tue 15 Sep 2015 06:01

Re: Error in Linq Query

Postby MariiaI » Wed 23 Sep 2015 11:50

We couldn't reproduce this error in our environment with the latest build of LinqConnect 4.5.835. Please create and send us a test project, with which this issue is reproducible. This will significantly speed up the process of determining the cause of the error and finding the solution for you.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Error in Linq Query

Postby dqrest » Tue 29 Sep 2015 12:28

Hello!

I send my simple project to support@devart.com where you can catch the following error:

"Devart.Data.Linq.Engine.ObjectReader`1[TN.Core.MainModule+MyCriterion]' cannot be converted to type 'System.Collections.Generic.IEnumerator`1[Core_Pages_FlatHandbookFilter+MyCriterion]'"!

Please, find out the desicion of this problem.

Thanks!
dqrest
 
Posts: 7
Joined: Tue 15 Sep 2015 06:01

Re: Error in Linq Query

Postby MariiaI » Wed 30 Sep 2015 10:01

We have contacted you by e-mail.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to LinqConnect (LINQ to SQL support)