Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class IncidentRepository
- {
- public static IList<AuditReport> GetAllIncidentsToAudit()
- {
- DetachedCriteria dc = DetachedCriteria.For<Incident>("i")
- .SetProjection(
- Projections.ProjectionList()
- .Add(Projections.Property("i.Id"), "IncidentId")
- .Add(Projections.Property("l.Id"), "LocationId")
- )
- .CreateCriteria("Locations", "l")
- .Add(Expression.Eq("l.PrimaryLocationFlag", "T"))
- .SetResultTransformer(Transformers.AliasToBean<AuditReport>());
- return ActiveRecordMediator<AuditReport>.FindAll(dc);
- }
- }
- public class AuditReport
- {
- public int IncidentId { get; set; }
- public int LocationId { get; set; }
- }
- 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.
- ISession sess = ActiveRecordMediator.GetSessionFactoryHolder().
- CreateSession(typeof(ActiveRecordBase));
- ICriteria criteria = sess.CreateCriteria<Incident>("i")
- .SetProjection(
- Projections.ProjectionList()
- .Add(Projections.Property("i.Id"), "IncidentId")
- .Add(Projections.Property("l.Id"), "LocationId")
- )
- .CreateCriteria("Locations", "l")
- .Add(Expression.Eq("l.PrimaryLocationFlag", "T"))
- .SetResultTransformer(Transformers.AliasToBean<AuditReport>());
- return criteria.List<AuditReport>();
- [Import( typeof( AuditReport ), "AuditReport" )]
- select new OrderSummary(o.Foo, count(o.Foo))
- from Orders o
- group by o.Bar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement