castle-activerecord

Any exprience with Castle ActiveRecord?

Hi all, I was searching for a light data access framework based on NHibernate. I needed simple CRUD and some simple HQL or LINQ-to-NHhibernate queries. Performance was not an important issue and applications which I'm working on have simple table structure but many tables. This data access framework is going to be used in a ASP.NET Webf...

Paging in ActiveRecord

Does CastleProject ActiveRecord support paging? I need to load only data which is now seen on the screen. If I use [HasMany], it will be loaded as a whole either immediately or at the first call (if lazy attribute is true). However I only need something like first 100 records (then maybe 100 next records). Another question is how to loa...

Problem with Select Distinct in CastleActiveRecord.

I want to execute follow command in ActiveRecord. select distinct(Name) from DbTemplateNw; I tried this code but it's alway return all record in table (there are many duplicate name). public static DbTemplateNw[] GetDistintTemplate() { DetachedCriteria distinctCriteria = DetachedCriteria.For(typeof(DbTemplateNw)) .SetProj...

Monorail Excpetion, "The given key was not present in the dictionary."

Hello All, I am quite blocked about an exception. I am using Active Record and Monorail. I was able to use the scaffold controllers in monorail, until I add new models. System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2[System.String,NHibernate.Ma...

How to use Linq with Castle ActiveRecord

I am playing around with Castle ActiveRecord and noticed that the download included the file, Castle.ActiveRecord.Linq.dll. I haven't found any documentation for using Linq with ActiveRecord, only some old blog posts. What is the usage pattern? Is Castle.ActiveRecord.Linq ready for production use? ...

How to Combine Castle ActiveRecord entities with normal NHibernate entities?

I am trying to integrate entities defined with ActiveRecord and entities mapped with plain-old .hbm files. I need to have associations between the two, i.e.: ActiveRecordEntity.HbmEntity & HbmEntity.ActiveRecordEntity The only thing I've bumped into that seems at all related is the ActiveRecordMediator but it didn't look like it wou...

Mapping Enums to Database with NHibernate/Castle ActiveRecord

There's a few other posts on mapping Enums to the DB with ActiveRecord, but none of them answer my question. I have an enum called OrderState: public enum OrderState {InQueue, Ordered, Error, Cancelled} And I have the following property on the table: [Property(NotNull = true, SqlType = "orderstate", ColumnType = "DB.EnumMapper, WebS...

Castle Active Record (Linq AND Validation) Problem

I am trying out Castle ActiveRecord. I want to use the Validation features AND the LINQ features. In order to use LINQ, you can either: My preference: Make your entities inherit from ActiveRecordLinqBase<T>, then to query: var blogs = (from b in Blog.Queryable select b).ToList(); Use ActiveRecordLinq.AsQueryable<T>, e.g.: var blogs ...

How can I get BelongsTo to automatically update for transient object in Castle ActiveRecord

Hi, I've just switched to Castle.ActiveRecord 2.1.0 and I'm puzzled about a behaviour change. I used to be able to update a child's parent-reference by calling Update on the parent and then refreshing the child. Now that doesn't work anymore, am I missing something completely? Or was I doing it wrong from the beginning? The code belo...

MySQL Master/Slave with Castle Activerecord

I have an existing web application using Castle Activerecord to interact with a single MySQL database. The Database has recently been reconfigured to replicate to a number of Slaves. How do you configure Castle Activerecord to direct writes to the MySQL Master and reads to the MySQL Slaves or are there other ways of achieving Master/Sla...

Good book on Castle Project?

Does anyone know of a good book on the Castle Project? I'm interested in learning more about any of the Castle projects (ActiveRecord, MonoRail, Windsor, anything!) and searches for Castle on Amazon are a little frustrating with the need to weed out all the fiction and nonsense. ...

Flush separate Castle ActiveRecord Transaction, and refresh object in another Transaction

I've got all of my ASP.NET requests wrapped in a Session and a Transaction that gets commited only at the very end of the request. At some point during execution of the request, I would like to insert an object and make it visible to other potential threads - i.e. split the insertion into a new transaction, commit that transaction, and ...

Castle ActiveRecord Class Table Inheritance

I'm trying to create Class Table Inheritance as in ( http://www.castleproject.org/activerecord/documentation/trunk/usersguide/typehierarchy.html ) So let's say I have 2 classes: [ActiveRecord("entity"), JoinedBase] public class Entity : ActiveRecordBase { private int id; private string name; private string type; ...and propert...

Castle ActiveRecord HasAndBelongsToMany issue

Hey, I'm using monorail/activerecord and was wondering how you handle adding items in a many to many relationship when the many to many table has a value in it besides just the 2 foreign keys. For example, Business and Amenity classes have a many to many relationship so there is a BusinessAmenity table. If the BusinessAmenity table on...

How to map table records to Any type using Castle ActiveRecord

I know it's possible to create Any relationships where the related record could be of any type. Is there a way to tell the ActiveRecord the records in a table belong to many different types even when there is no relationships? For example I have a table in which there is a string field that stores the type of each record in table. I'd l...

Unnecessarily updates in CastleActiveRecord

Hi! I have two ActiveRecord classes class Product : ActiveRecordBase<Product> { private IList<Usage> _usages = new List<Usage>(); ... [HasMany( ColumnKey="produkt_id", Inverse=true, Cascade=ManyRelationCascadeEnum.None)] public IList<Usage> Usages { get { return _usages; } set {...

Castle ActiveRecord cascading delete all orphans with HasAndBelongsToMany is deleting non-orphaned objects

I'm having a lot of trouble with cascading delete all orphans through a HasAndBelongsToMany relationship using Castle ActiveRecord/NHibernate. I have Facilities which can have different types of Addresses. They are joined by a table called FacilityAddress which just has a FacilityID and an AddressID. Here is what I want the code to do...

How to execute custom query and return generic list?

I can only seem to find how to return arrays from my function. Here is my model: [ActiveRecord("incident")] public class Incident : ActiveRecordBase<Incident> { public Incident() { } [PrimaryKey("id")] public int Id { get; set; } [Property("name")] public int Name { get; set; } } I'm currently using SimpleQuery h...

Castle ActiveRecord JoinedKey is not set

I am using "Class Table Inheritance - Using joined subclasses" as described here: http://www.castleproject.org/activerecord/documentation/trunk/usersguide/typehierarchy.html The following code is partly copied from there. [ActiveRecord("entity"), JoinedBase] public class Entity : ActiveRecordBase { ... private int id; [Pri...

1 to N Relationship Mappings with Castle ActiveRecord

Hello! This is my first post on Stack Overflow! (yay!) I'm having trouble with a Castle ActiveRecord mapping, which I thought would be a pretty common scenario, but maybe I didn't "google" right. I have one entity called Product, and another entity called Warranty. Product has two properties on it (among others), each of type Warrant...