System.Linq.Dynamic.Core icon indicating copy to clipboard operation
System.Linq.Dynamic.Core copied to clipboard

Accessing DbGeography methods/properties

Open czielin opened this issue 8 years ago • 5 comments

I am now working on querying some fields that are mapped via Entity Framework to the Sql Server geography type. The following two queries:

queryable.Where("p.any(c.geographic.Union(@0).Area == 0)", parameters.ToArray()); queryable.Where("p.any(@0.Difference(c.geographic).IsEmpty)", parameters.ToArray());

result in the following error:

System.Linq.Dynamic.Core.Exceptions.ParseException: 'Methods on type 'DbGeography' are not accessible'

A simple geographic query, like the following, works as expected:

p.any(c.geographic.Intersects(@0))

The parameters object contains a single DbGeography object.

Are the above two queries expected to work? Do I maybe again have the incorrect query syntax?

Thanks!

czielin avatar Jan 04 '18 22:01 czielin

It will take me a bit to build some proper tests around it, but I added the following to the predefined types, and the above queries appear to be translating to proper TSQL now.

_predefinedTypesHelper.TryAdd("System.Data.Entity.Spatial.DbGeography, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 2);

Once I've had a chance to test some more I'll create a pull request for this.

@StefH thanks for your prior tip on getting the solution to properly build. Turns out it came in handy.

czielin avatar Jan 04 '18 23:01 czielin

All right, testing was successful. I added a pull request.

czielin avatar Jan 05 '18 04:01 czielin

Thanks a lot!

StefH avatar Jan 05 '18 07:01 StefH

Wow, I see you created a new release already. Thanks!

czielin avatar Jan 05 '18 12:01 czielin

You are welcome!

StefH avatar Jan 05 '18 18:01 StefH