On Tuesday, January 24, 2017 at 8:29:26 AM UTC-5, Denis Pujdak wrote:
>
> Hi everyone,
>
> I got stuck on my implementation using composite user type Instant:
>
I'm not sure what you are trying to do there, but if a Utc/Local switch is
your goal, it's a flawed approach IMO.
You, your customers, and/or end-users are much better served by leaving
such decisions to whatever Views are involved. Then just agree that the
database will contain Utc, or a known local, i.e. "base unit" if you will.
If you really need to store "local" versus Utc details, then consider a
VARCHAR or NVARCHAR capable of handling an ISO format.
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.