Error in Linq execution
Posted: Tue 15 Sep 2015 06:23
Hi!
I faced to some problems in Linq execution. I have Devart.Data.Linq 4.4.697.0 and Devart.Data.Oracle.Linq 4.4.697.0 and Devart.Data.Oracle. 8.4.359.0.
------------------------------------------------------------------------
Part A.
I represent the code which work right:
var dataC = from c in All.SysFilterCriterions
where c.FilterNo == filterNo
orderby c.OrderNo
select c;
var listC = dataC.ToList();
------------------------------------------------------------------------
------------------------------------------------------------------------
Part B.
But in the following code I have some errors:
var crits = (from c in All.SysFilterCriterions
where c.FilterNo == filterNo
orderby c.OrderNo
select
new MyCriterion()
{
No = c.No,
FieldNo = c.FieldNo,
Caption = c.Caption
});
var dataQ = crits.ToList();
private class MyCriterion
{
public long No { get; set;}
public long? FieldNo{ get; set;}
public string Caption{ get; set;}
}
I have the following error: "Object of type 'Devart.Data.Linq.Engine.ObjectReader`1[Core_Pages_FlatHandbookFilter+MyCriterion]' cannot be converted to type 'System.Collections.Generic.IEnumerator`1[Core_Pages_FlatHandbookFilter+MyCriterion]'."
------------------------------------------------------------------------
I have not see any difference between Part A and Part B.
What happends? Please, help me!
I faced to some problems in Linq execution. I have Devart.Data.Linq 4.4.697.0 and Devart.Data.Oracle.Linq 4.4.697.0 and Devart.Data.Oracle. 8.4.359.0.
------------------------------------------------------------------------
Part A.
I represent the code which work right:
var dataC = from c in All.SysFilterCriterions
where c.FilterNo == filterNo
orderby c.OrderNo
select c;
var listC = dataC.ToList();
------------------------------------------------------------------------
------------------------------------------------------------------------
Part B.
But in the following code I have some errors:
var crits = (from c in All.SysFilterCriterions
where c.FilterNo == filterNo
orderby c.OrderNo
select
new MyCriterion()
{
No = c.No,
FieldNo = c.FieldNo,
Caption = c.Caption
});
var dataQ = crits.ToList();
private class MyCriterion
{
public long No { get; set;}
public long? FieldNo{ get; set;}
public string Caption{ get; set;}
}
I have the following error: "Object of type 'Devart.Data.Linq.Engine.ObjectReader`1[Core_Pages_FlatHandbookFilter+MyCriterion]' cannot be converted to type 'System.Collections.Generic.IEnumerator`1[Core_Pages_FlatHandbookFilter+MyCriterion]'."
------------------------------------------------------------------------
I have not see any difference between Part A and Part B.
What happends? Please, help me!