ExpressionParameterVisitor
NHibernateUtil.GuessType(expression.Type)

We can't guess the type without the "usage context".
myClass.MyProperty == something

to really guess/know the type of "something" we have to know the mapping of
"MyProperty".

We may have an ugly patch-extension method where the user can specify the
NH's IType but... well... that will be a patch not a solution.

On Thu, Aug 19, 2010 at 3:46 PM, David Pfeffer <[email protected]> wrote:

> Right, which is exactly what I'm working on right now...
>
> What I'm proposed is a fix for the issues relating to the LINQ provider
> custom types. What do you all think of the solution?
>
>
> On Thu, Aug 19, 2010 at 11:41 AM, Fabio Maulo <[email protected]>wrote:
>
>> I think that first we have to fix issues related to Linq-Provider and
>> custom-types then we have to add some linq-extensions inside
>> NHibernate-Spatial (as it has HQL extensions).
>>
>>
>> On Thu, Aug 19, 2010 at 11:02 AM, David Pfeffer <[email protected]>wrote:
>>
>>> An example from NH Spatial --
>>>
>>> I have a type...
>>>
>>> public class Breadcrumb
>>> {
>>>      public virtual int Id { get; set; }
>>>      public virtual IGeometry Position { get; set; }
>>>      public virtual string Description { get; set; }
>>> }
>>>
>>> ...and in my code I do the following...
>>>
>>> IGeometry center;
>>> // code here to set the center to a useful point
>>> var breadcrumbsWithinDistance = session.Query<Breadcrumb>().Where(x =>
>>> x.Position.Distance(center) < 500);
>>>
>>> Now, how would the LINQ engine know the mapping of *center*? Since it
>>> isn't a property of a mapped class there's nothing already specified here
>>> for what user type to use.
>>>
>>> I propose that line could be replaced as...
>>>
>>> var breadcrumbsWithinDistance = session.Query<Breadcrumb>().Where(x =>
>>> x.Position.Distance(center.AsUserType(new 
>>> NHibernate.Type.CustomType(typeof(NHibernate.Spatial.Type.MsSql2008GeographyType),
>>>  null)
>>> )) < 500);
>>>
>>> (or whatever other user type is appropriate for that database engine)
>>>
>>> What do you think?
>>>
>>>
>>> On Mon, Aug 16, 2010 at 5:16 PM, Fabio Maulo <[email protected]>wrote:
>>>
>>>>
>>>> El 16/08/2010, a las 12:14, David Pfeffer <[email protected]>
>>>> escribió:
>>>>
>>>> I would attempt to write a fix, but this isn't just a bug. There's a
>>>> design issue to be resolved here as to how to go about implementing this.
>>>>
>>>>
>>>> I'm not so sure about " a design issue"...
>>>>
>>>>
>>>> One idea I have is to create an extension method, WithUserType(this
>>>> object obj, IType type) that will be used to inform the LINQ provider as to
>>>> the type (UserType, etc.).
>>>>
>>>>
>>>> Try to write an example where the Type can't be inferred.
>>>> Thanks.
>>>>
>>>>
>>>> If this sounds like a good idea, would anyone be able to provide a few
>>>> pointers as to where to look to hook this in? I will take a look and see if
>>>> I can patch.
>>>>
>>>> Thanks.
>>>>
>>>> On Mon, Aug 16, 2010 at 10:53 AM, Fabio Maulo < <[email protected]>
>>>> [email protected]> wrote:
>>>>
>>>>> Known issue
>>>>> <http://216.121.112.228/browse/NH/component/10120>
>>>>> http://216.121.112.228/browse/NH/component/10120
>>>>>
>>>>>
>>>>> On Fri, Aug 13, 2010 at 2:54 PM, David Pfeffer < <[email protected]>
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hello all,
>>>>>>
>>>>>> So I'm having a bit of difficulty trying to build a LINQ to NH Spatial
>>>>>> provider. Specifically, I have not found a way to specify the user type 
>>>>>> for
>>>>>> IGeometry types. So, even though I have the backend LINQ parser code 
>>>>>> plugged
>>>>>> in, queries fail due to "No persister for: GeoAPI.Geometries.IGeometry."
>>>>>>
>>>>>> In Criteria and HQL specifying the user type is easy. How do I specify
>>>>>> the user type for a LINQ query so that my backend code is invoked?
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Fabio Maulo
>>>>>
>>>>>
>>>>
>>>
>>
>>
>> --
>> Fabio Maulo
>>
>>
>


-- 
Fabio Maulo

Reply via email to