Select Distinct with CastleActiveRecord


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public static IList<DbTemplateNw> GetDistintTemplateTwo()
  2. {
  3. ISession session = ActiveRecordMediator.GetSessionFactoryHolder().CreateSession(typeof(DbTemplateNw));
  4. ICriteria criteria = session.CreateCriteria(typeof(DbTemplateNw));
  5. criteria.SetProjection(
  6. Projections.Distinct(Projections.ProjectionList()
  7. .Add(Projections.Alias(Projections.Property("Name"), "Name"))));
  8.  
  9. criteria.SetResultTransformer(
  10. new NHibernate.Transform.AliasToBeanResultTransformer(typeof(DbTemplateNw)));
  11.  
  12. IList<DbTemplateNw> result = criteria.List<DbTemplateNw>();
  13. return result;
  14. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.