Advertisement
Guest User

Untitled

a guest
Sep 14th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. public class IncidentRepository
  2. {
  3. public static IList<AuditReport> GetAllIncidentsToAudit()
  4. {
  5. DetachedCriteria dc = DetachedCriteria.For<Incident>("i")
  6. .SetProjection(
  7. Projections.ProjectionList()
  8. .Add(Projections.Property("i.Id"), "IncidentId")
  9. .Add(Projections.Property("l.Id"), "LocationId")
  10. )
  11. .CreateCriteria("Locations", "l")
  12. .Add(Expression.Eq("l.PrimaryLocationFlag", "T"))
  13. .SetResultTransformer(Transformers.AliasToBean<AuditReport>());
  14.  
  15. return ActiveRecordMediator<AuditReport>.FindAll(dc);
  16. }
  17. }
  18.  
  19. public class AuditReport
  20. {
  21. public int IncidentId { get; set; }
  22. public int LocationId { get; set; }
  23. }
  24.  
  25. You have accessed an ActiveRecord class that wasn't properly initialized. There are two possible explanations: that the call to ActiveRecordStarter.Initialize() didn't include castle.AuditReport class, or that castle.AuditReport class is not decorated with the [ActiveRecord] attribute.
  26.  
  27. ISession sess = ActiveRecordMediator.GetSessionFactoryHolder().
  28. CreateSession(typeof(ActiveRecordBase));
  29. ICriteria criteria = sess.CreateCriteria<Incident>("i")
  30. .SetProjection(
  31. Projections.ProjectionList()
  32. .Add(Projections.Property("i.Id"), "IncidentId")
  33. .Add(Projections.Property("l.Id"), "LocationId")
  34. )
  35. .CreateCriteria("Locations", "l")
  36. .Add(Expression.Eq("l.PrimaryLocationFlag", "T"))
  37. .SetResultTransformer(Transformers.AliasToBean<AuditReport>());
  38.  
  39. return criteria.List<AuditReport>();
  40.  
  41. [Import( typeof( AuditReport ), "AuditReport" )]
  42.  
  43. select new OrderSummary(o.Foo, count(o.Foo))
  44. from Orders o
  45. group by o.Bar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement