Print Page | Close Window

Anonymous types

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2910
Printed Date: 13-May-2026 at 9:25pm


Topic: Anonymous types
Posted By: danjal
Subject: Anonymous types
Date 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?

 

 




Replies:
Posted By: sbelini
Date Posted: 22-Aug-2011 at 11:29am
Hi danjal,
The query is possible.
 
Is the GeoXY type present in both client and server?
 
Silvio.


Posted By: danjal
Date 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; }

}



Posted By: sbelini
Date 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 - uploads/892/SL_AnonymousTypes.zip
 
Can you provide a reproducible test case (against NorthwindIB please) ?
 
Silvio.



Print Page | Close Window