Comparison operators on multi-column user types aren't very useful. The
behaviour you see will sometimes be useful for equaliye operators though.

What you are trying to do looks a bit redundant, and I would suggest you
avoid storing what is essentially the same value twice, unless you have a
very clear idea on what you will gain by it.

You could explore using a component instead. That way you can write your
queries with the condition on the proper "subvalue".

/Oskar

2017-01-24 12:32 GMT+00:00 Denis Pujdak <[email protected]>:

> Hi everyone,
>
> I got stuck on my implementation using composite user type Instant:
>
> public class InstantUserType : ICompositeUserType
> {
>     public override string[] PropertyNames
>     {
>         get
>         {
>             return new string[2] { "Utc", "Local" };
>         }
>     }
>
>     public override IType[] PropertyTypes
>     {
>         get
>         {
>             return new IType[2] { NHibernateUtil.UtcDateTime,
> NHibernateUtil.DateTime };
>         }
>     }
>
>     public override Type ReturnedClass
>     {
>         get
>         {
>             return typeof(Instant);
>         }
>     }
> }
>
> This it strange because when I use comparison like:
>
> var dueDate = new Instant(DateTime.UtcNow);
> var result = ((IQueryable)myRepository).Where(x => x.DueDate <= dueDate
> ).ToList();
>
> the generated query looks like:
>
> select * from SomeTable where DueDateUtc <= @p0 and DueDateLocal <= @p0
>
> Does anyone know what can I do to prevent NHibernate from searching by the
> second parameter. It must be like:
>
> select * from SomeTable where DueDateUtc <= @p0
>
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/nhusers.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to