In the implementation of of your Generator for your extension you can specify the IType. In this way you have a real LINQ extension working in RAM as it will work using NHibernate.
If you are in a "safe-zone" where you can have the reference to NHibernate dll, you can use any other query-system provided by NHibernate, you don't need LINQ. On Thu, Aug 19, 2010 at 11:46 PM, David Pfeffer <[email protected]> wrote: > I've seen this blog post but I'm not sure how it applies. I'm aware of how > you'd implement ExampleMethod but not how you'd specify the user type for > mapping of ExampleType. > > > On Thu, Aug 19, 2010 at 10:44 PM, Fabio Maulo <[email protected]>wrote: > >> >> http://fabiomaulo.blogspot.com/2010/07/nhibernate-linq-provider-extension.html >> >> >> On Thu, Aug 19, 2010 at 11:41 PM, David Pfeffer <[email protected]>wrote: >> >>> That might work for instances of direct comparison, but what of an >>> extension method where the arguments are different... for example this >>> theoretical method: >>> >>> public static bool ExampleMethod(this int x, ExampleType y) { ... } >>> >>> In this example you have a usage but the usage isn't going to help you >>> guess the mapping type for ExampleType. The only way I can think of doing >>> that is with the extension method patch. If you have another idea I'd be >>> excited to hear it though. Otherwise would that be an acceptable solution >>> and should I go ahead with it? >>> >>> >>> On Thu, Aug 19, 2010 at 9:58 PM, Fabio Maulo <[email protected]>wrote: >>> >>>> 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 >>>> >>>> >>> >> >> >> -- >> Fabio Maulo >> >> > -- Fabio Maulo
