Search Results

Search found 3 results on 1 pages for 'user315648'.

Page 1/1 | 1 

  • NHibernate Criteria Find by Id

    - by user315648
    Hello, I have 2 entities: public class Authority : Entity { [NotNull, NotEmpty] public virtual string Name { get; set; } [NotNull] public virtual AuthorityType Type { get; set; } } public class AuthorityType : Entity { [NotNull, NotEmpty] public virtual string Name { get; set; } public virtual string Description { get; set; } } Now I wish to find all authorities from repository by type. I tried doing it like this: public IList<Authority> GetAuthoritiesByType(int id) { ICriteria criteria = Session.CreateCriteria(typeof (Authority)); criteria.Add(Restrictions.Eq("Type.Id", id)); IList<Authority> authorities = criteria.List<Authority>(); return authorities; } However, I'm getting an error that something is wrong with the SQL ("could not execute query". The innerexception is following: {"Invalid column name 'TypeFk'.\r\nInvalid column name 'TypeFk'."} Any advice ? Any other approach ? Best wishes, Andrew

    Read the article

  • How to group a period of time into yearly periods ? (split timespan into yearly periods)

    - by user315648
    I have a range of two datetimes: DateTime start = new DateTime(2012,4,1); DateTime end = new DateTime(2016,7,1); And I wish to get all periods GROUPED BY YEAR between this period. Meaning the output has to be: 2012-04-01 - 2012-12-31 2013-01-01 - 2013-12-31 2014-01-01 - 2014-12-31 2015-01-01 - 2015-12-31 2016-01-01 - 2016-07-01 Preferably the output would be in IList<Tuple<DateTime,DateTime>> list. How would you do this ? Is there anyway to do this with LINQ somehow ? Oh and daylight saving time is not absolutely critical, but surely a bonus. Thanks!

    Read the article

1