castle-activerecord

Castle Project ActiveRecord with XML

Can Castle ActiveRecord write to XML document? Any links to sample code? ...

Castle ActiveRecord - Always updating children, why?

Dear All: Hi! These last two weeks have been my first experience with Castle ActiveRecord, and with the ActiveRecord pattern in general. I'm working on a large system that uses it frequently, and I have been finding some strange SQL transaction issues (such as the one below) as I work on it. I'll give a simplified version of the one ...

Setting Multiple DataKeyNames in GridView from different ActiveRecord table objects

I'm trying to set two datakeys using the DataKeyNames property of an asp.net GridView. I have a simplequery as follows: Castle.ActiveRecord.Queries.SimpleQuery<ARMapping.CONFIGURATION> c = new Castle.ActiveRecord.Queries.SimpleQuery<ARMapping.CONFIGURATION>(@" select c from CONFIGURATION c left join c.LUserConfiguration luc left joi...

NHibernate / Castle activerecord: How to get object that caused database exception?

Can I somehow get the object that caused a GenericADOException (constraint exception)? Or How can I only flush one object so I can tell which one is the problem. I have a list of object that are displayed in a form, and can be edited and added to. On flush it gives me a database exception but I can't tell which object gave the exceptio...

Howto automatically fill fields during save or update with Castle ActiveRecord

The Problem: All tables in our database have CreatedDate, CreatedBy, ChangedDate, ChangedBy fields which I want to be set automatically when Saving / Updating an ActiveRecord entity. My first try was to override the Save() and Update() methods. But these methods only get called when I do a direct Save() or Update() on the entity. They a...

Best Practices for Images in a Model with Castle ActiveRecord/MonoRail

Our "user" model needs a small profile picture on it, and I'm not entirely sure how to handle it. Of course we could just save it to a folder on disk and store the path/filename to the database, but I think I'd rather have it stored in the DB itself. My first thought was to have a property on the model like this: [Property] public ...

How to implement CreatedAt Property with Castle ActiveRecord

Say I want to create a class called EntityWithCreatedAt: class Entity<T> : ActiveRecordBase<T> { [PrimaryKey] public int Id { get; set; } } class EntityWithCreatedAt<T> : Entity<T> { [Property] public DateTime CreatedAt { get; set; } } What is the best way to populate the CreatedAt field? Do I just do it in EntityWithCreated...

How do I use ValidateDecimal attribute in Castle.ActiveRecord?

I have a class that inherits ActiveRecordValidationBase that contains the following property: [Property] [ValidateDecimal] public Decimal UnitCost { get; set; } I also have a UnitCostTextBox that accepts input for said UnitCost. What I would like to do is perform validation once using Castle's validators. However, it seems that befo...

Visualization of ActiveRecord / NHibernate Entity Model

Has anyone come across a tool to visualize an ActiveRecord / NHibernate entity model? ...

Castle ValidateEmail Attribute fails on plus sign

I am using Castle Validators on my model. I have an EmailAddress property defined like so: [ValidateEmail] public string EmailAddress { get; set; } The problem is that the regex (?) that the ValidateEmail attribute uses is incorrect. For instance, if I put in an email address like [email protected], it validates correctly, but if I put in...

Lucene.NET indexes are not updating when dealing with many-to-many relationships using NHibernate.Search

I have integrated NHibernate.Search into my web app by following tutorials from the following sources: NHibernate.Search using Lucene.NET Full Text Index (Part 1) Using NHibernate.Search with ActiveRecord I have also successfully batch-indexed my database, and when testing against Luke, I can search for terms that reside in whatever ...

Castle ActiveRecord error "Session is closed"

Hello, I'm trying to get started with Castle ActiveRecord but I'm stuck trying to make it work in an ASP.NET (MVC, if it matters) application. In fact I'm getting an ObjectDisposedException during a query with the following message: Session is closed! Object name: 'ISession'. I'm initializing ActiveRecord from an XML file (as shown i...

Automatic Schema Validation using NHibernate/ActiveRecord

Hi, let's assume I have a table of Products with columns: Id, Name, Price and using NHibernate (or ActiveRecord) I map the table to the POCO: public class Product { public virtual long Id { get; set; } public virtual string Name { get; set; } public virtual double Price { get; set; } } Now if someday a new column named ...

NHibernate: Creating a criteria which applies for all queries on a table

Using Castle ActiveRecord / NHibernate: Is there a way you can force an ICriterion on all queries on a table? For example, a good amount of of my tables have a "UserId" column. I might want to ensure that I am always selecting rows for the logged in user. I can easily create an ICriterion object, but I am forced to supply it for differe...

Flushing with Castle ActiveRecord

i saw that i can use SessionScope and have inserts inside the scope of the SessionScope and do flush at the end of the scope. my question is if i can define in some way that after, let's say, every 10 insertions/saves of objects, that they will automatically be flushed to the db. in other words i want to be able to configure the way i ...

How do you do joins in hibernate activerecord?

How do I do a join that would return me results similar to- SELECT * FROM Project LEFT JOIN ProjectRegion ON ProjectRegion.id = Project.projectRegion I currently use the syntax- Project[] projects = Project.FindAll(); My tables are setup with ActiveRecord/hibernate as follows - [ActiveRecord] public class ProjectRegion...

ASP.NET MVC 1.0 and Castle ActiveRecord 2.0 Lazy Loading

How do I access a lazy loaded property of an ActiveRecord model from within the view? I have a news model that Belongs to a Category Model, both of which are marked as Lazy=true I'm able to access a lazy loaded property in my view by doing the following in my controller using (new SessionScope()) { results = _service.FindAllNews(s...

Castle ActiveRecord/NHibernate System.Data.Services dependency and Mono 2.4.2.3

Getting the following compilation error trying to port ASP.Net MVC application using Castle ActiveRecord to a mod_mono server. Is System.Data.Services not available with mono? If not, do I have to throw out version 2.0 of Castle ActiveRecord framework since it has this dependency, or is there an alternative? ** (/usr/lib/mono/2.0/gmcs...

PostSharp: OnMethodBoundaryAspect doesn't get called

Hi I'm using PostSharp to apply a CompoundAspect to a ActiveRecord class (from CastleProject). The code looks like this: public override void ProvideAspects(object targetElement, LaosReflectionAspectCollection collection) { Type targetType = (Type)targetElement; RevertibleSubAspect revertible = new RevertibleSubAspect(); re...

SubSonic vs. Castle ActiveRecord

For an upcoming project C# code needs to be written around a legacy Oracle database. It will be very data centric, because most of the code will deal with data manipulation -- there are almost no business rules. So I decided against a full blown ORM and opted for an Active Record approach. I come across two options: SubSonic and Castle ...