New Posts New Posts RSS Feed: Anonymous types
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Anonymous types

 Post Reply Post Reply
Author
danjal View Drop Down
Groupie
Groupie


Joined: 20-Sep-2010
Posts: 43
Post Options Post Options   Quote danjal Quote  Post ReplyReply Direct Link To This Post Topic: Anonymous types
    Posted: 19-Aug-2011 at 6:33am

We have a query that looks like this:

var pg = entity as EntPointGroup;

var query = p_manager.EntPointSet

.Where(p => p.p_pointGroup.p_pointGroupID == pg.p_pointGroupID)

.Where(p => !(p.p_geoX == 0 && p.p_geoY == 0))

.GroupBy(p => new {p.p_pointGroupID})

.Select(g => new

{

m_maxGeoX = g.Max(p => p.p_geoX),

m_minGeoX = g.Min(p => p.p_geoX),

m_maxGeoY = g.Max(p => p.p_geoY),

m_minGeoY = g.Min(p => p.p_geoY)

});

 

It queries for points under a point group. Then we want the min- and maxvalues for x and y from the coordinates of these points to determine a boundary that contains all these points.

The result of this query is an anonymous type and this works fine.

 

But if I begin moving the points and there by changing their coordinates in the entity model and run the query again – I get the same min max values as before.

This is because it fetches the data from the datasource every time and not from the entity model.

 

If we make a known type GeoXY and query like this:

var pg = entity as EntPointGroup;

var query = p_manager.EntPointSet

.Where(p => p.p_pointGroup.p_pointGroupID == pg.p_pointGroupID)

.Where(p => !(p.p_geoX == 0 && p.p_geoY == 0))

.GroupBy(p => new {p.p_pointGroupID})

.Select(g => new GeoXY

{

m_maxGeoX = g.Max(p => p.p_geoX),

m_minGeoX = g.Min(p => p.p_geoX),

m_maxGeoY = g.Max(p => p.p_geoY),

m_minGeoY = g.Min(p => p.p_geoY)

});

 

We get this error:

Caught exception: System.Exception: Unable to locate type: System.Linq.IQueryable`1[[C2Net.CommonClasses.GeoXY, C2NetDomainModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e. Check that the assembly holding this type is available in the bin/exe folder. Also check that both your assemblies and DevForce assemblies have the expected version number on both client and server. at IdeaBlade.Core.TypeWrapper.FindType() at IdeaBlade.Core.TypeWrapper.Restore() at IdeaBlade.Core.TypeWrapper.get_Type() at IdeaBlade.Linq.ExpressionBlock.set_TypeWrapper(.....

 

We have added GeoXY to the same class that all of our other known types are located.

 

Is it even possible to query like this on the entity model?

 

 

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 22-Aug-2011 at 11:29am
Hi danjal,
The query is possible.
 
Is the GeoXY type present in both client and server?
 
Silvio.
Back to Top
danjal View Drop Down
Groupie
Groupie


Joined: 20-Sep-2010
Posts: 43
Post Options Post Options   Quote danjal Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2011 at 2:31am

Hi Silvio,

 

Yes it is present in both client and server

 

[System.Runtime.Serialization.DataContract]

public class GeoXY : IdeaBlade.EntityModel.IKnownType

{

[System.Runtime.Serialization.DataMember]

       public double m_maxGeoX { get; set; }

       [System.Runtime.Serialization.DataMember]

       public double m_minGeoX { get; set; }

       [System.Runtime.Serialization.DataMember]

       public double m_maxGeoY { get; set; }

       [System.Runtime.Serialization.DataMember]

       public double m_minGeoY { get; set; }

}

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2011 at 10:02am
Danjal,
 
I can't repro the issue here.
I have attached a simple sample app using a custom type: uploads/892/SL_AnonymousTypes.zip
 
Can you provide a reproducible test case (against NorthwindIB please) ?
 
Silvio.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down