Posted By

wearetherock on 06/02/10


Tagged

distinct castleactiverecord


Versions (?)

Select Distinct with CastleActiveRecord


 / Published in: C#
 

  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  

You need to login to post a comment.