Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6531951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:56:26+00:00 2026-05-25T09:56:26+00:00

I am using the TIME datatype from SQL Server 2008 and I am having

  • 0

I am using the TIME datatype from SQL Server 2008 and I am having some problems getting it to work with NHibernate.

public TimeTableEventMap()
{
    Id(x => x.Id)
    Map(x => x.Day).NvarcharWithMaxSize().Not.Nullable();
    Map(x => x.StartTime).Length(4).TimeDataType().Not.Nullable();
    Map(x => x.Endtime).Length(4).TimeDataType().Not.Nullable();
    References(x => x.TimeTable).Not.Nullable().Cascade.All();
    References(x => x.RequiredSettings).Not.Nullable().Cascade.All();
}

/// <summary>
///  MS Sql 2008 date type.
/// </summary>
/// <param name="map"></param>
/// <returns></returns>
public static PropertyPart TimeDataType(this PropertyPart map)
{
   return map.CustomSqlType("time");
}

public class TimeTableEvent
{
    public virtual int Id { get; private set; }
    public virtual DayOfWeek Day { get; set; }
    public virtual DateTime StartTime { get; set; }
    public virtual DateTime Endtime { get; set; }
    public virtual TimeTable TimeTable { get; set; }
    public virtual RequiredSetting RequiredSettings { get; set; }
}   

I get this error

NHibernate.Exceptions.GenericADOException was caught
Message=could not execute query
[ SELECT TOP (@p0) this_.TimeTableEventId as TimeTabl1_15_1_,
this_.Day as Day15_1_, this_.StartTime as StartTime15_1_,
this_.Endtime as Endtime15_1_, this_.TimeTableId as TimeTabl5_15_1_,
this_.RequiredSettingsId as Required6_15_1_,
requiredse2_.RequiredSettingsId as Required1_10_0_,
requiredse2_.BackgroundColor as Backgrou2_10_0_, requiredse2_.Title as
Title10_0_ FROM TimeTableEvents this_ inner join RequiredSettings
requiredse2_ on
this_.RequiredSettingsId=requiredse2_.RequiredSettingsId WHERE
this_.TimeTableId in (@p1) ]
Positional parameters: #0>14
[SQL: SELECT TOP (@p0) this_.TimeTableEventId as TimeTabl1_15_1_,
this_.Day as Day15_1_, this_.StartTime as StartTime15_1_,
this_.Endtime as Endtime15_1_, this_.TimeTableId as TimeTabl5_15_1_,
this_.RequiredSettingsId as Required6_15_1_,
requiredse2_.RequiredSettingsId as Required1_10_0_,
requiredse2_.BackgroundColor as Backgrou2_10_0_, requiredse2_.Title as
Title10_0_ FROM TimeTableEvents this_ inner join RequiredSettings
requiredse2_ on
this_.RequiredSettingsId=requiredse2_.RequiredSettingsId WHERE
this_.TimeTableId in (@p1)]
Source=NHibernate
SqlString=SELECT TOP (@p0) this_.TimeTableEventId as
TimeTabl1_15_1_, this_.Day as Day15_1_, this_.StartTime as
StartTime15_1_, this_.Endtime as Endtime15_1_, this_.TimeTableId as
TimeTabl5_15_1_, this_.RequiredSettingsId as Required6_15_1_,
requiredse2_.RequiredSettingsId as Required1_10_0_,
requiredse2_.BackgroundColor as Backgrou2_10_0_, requiredse2_.Title as
Title10_0_ FROM TimeTableEvents this_ inner join RequiredSettings
requiredse2_ on
this_.RequiredSettingsId=requiredse2_.RequiredSettingsId WHERE
this_.TimeTableId in (@p1)

StackTrace:
at NHibernate.Loader.Loader.DoList(ISessionImplementor
session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor
session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor
session, QueryParameters queryParameters, ISet1 querySpaces, IType[]
resultTypes)
at NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor
session)
at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria,
IList results)
at NHibernate.Impl.CriteriaImpl.List(IList results)
at NHibernate.Impl.CriteriaImpl.List[T]()
at NHibernate.Criterion.QueryOver
1.ListU
at NHibernate.Criterion.QueryOver`1.NHibernate.IQueryOver.ListU
at TimeTableRepo.cs:line 47
at TimeTableService.cs:line 43
InnerException: System.FormatException
Message=Input string ’16:00:00′ was not in the correct
format.
Source=NHibernate
StackTrace:
at NHibernate.Type.DateTimeType.Get(IDataReader rs,
Int32 index)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[]
names, ISessionImplementor session, Object owner)
at NHibernate.Type.AbstractType.Hydrate(IDataReader
rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Persister.Entity.AbstractEntityPersister.Hydrate(IDataReader
rs, Object id, Object obj, ILoadable rootLoadable, String[][]
suffixedPropertyColumns, Boolean allProperties, ISessionImplementor
session)
at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i,
Object obj, String instanceClass, EntityKey key, String rowIdAlias,
LockMode lockMode, ILoadable rootPersister, ISessionImplementor
session)
at NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i,
ILoadable persister, EntityKey key, LockMode lockMode, String
rowIdAlias, EntityKey optionalObjectKey, Object optionalObject, IList
hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRow(IDataReader rs,
ILoadable[] persisters, EntityKey[] keys, Object optionalObject,
EntityKey optionalObjectKey, LockMode[] lockModes, IList
hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet,
ISessionImplementor session, QueryParameters queryParameters,
LockMode[] lockModeArray, EntityKey optionalObjectKey, IList
hydratedObjects, EntityKey[] keys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor
session, QueryParameters queryParameters)
InnerException: System.InvalidCastException
Message=Unable to cast object of type
‘System.TimeSpan’ to type ‘System.IConvertible’.
Source=mscorlib

public List<TimeTableEvent> GetTimeTableEvents(Student student, List<int> timeTableIds)
{
    TimeTableEvent tAlias = null;

    List<TimeTableEvent> allEvents = session.QueryOver<TimeTableEvent>(() => tAlias)
        .Where(Restrictions.In(Projections.Property(() => tAlias.TimeTable.Id), timeTableIds))
        .Fetch(r => r.RequiredSettings).Eager
        .TransformUsing(Transformers.DistinctRootEntity)
        .Take(QueryLimits.TimeTableEvents)
        .List<TimeTableEvent>().ToList();

    return allEvents;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:56:27+00:00Added an answer on May 25, 2026 at 9:56 am

    Date/Time Support in NHibernate

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using SQL Server 2005 Date Time 20060701 090000 20060702 020000 20060703 180000 ... Date
I'm compiling some C# and VB code at run time using the CodeDomProvider, CompilerInfo,
If I wanted to work using dates and time going millions of years into
New to javascript/jquery and having a hard time with using this or $(this) to
I have a capistrano deployment recipe I've been using for some time to deploy
Using SQL Server 2000 My Query. SELECT (Format(IIf(CLng(OutTime) > 180000, CDate('18:00:00'), CDate(Format(OutTime, '00:00:00'))) -
I am linking some fortran code (f90) from matlab using mex and I am
I am attempting to pull some information from my tnsnames file using regex. I
This is my first time using joomla. I don't know if I'm using the
I do this all the time using VNC and it is very easy, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.