castle-activerecord

Parameterizing a HQL IN clause using HqlBasedQuery?

How do you pass a list of things for the 'in' clause in Nhibernate HQL? e.g. // data input from the user interface, not known at compile time object[] productIds = {1, 17, 36, ... }; string hqlQuery = @" from Product as prod where prod.Id in ( ? )"; HqlBasedQuery query = new HqlBasedQuery(typeof(Product...

Nhibernate HQL where IN query

Im trying to return a SimpleQuery list that queries a single table and uses IN. I can get this to work using return new List<Jobs>( ActiveRecordMediator<Jobs>.FindAll(Expression.In("ServiceId", ids)) ); However this is really really really slow. So id like to do something like this SimpleQuery<Job> query = new SimpleQuery<Jo...

NHibernate and database connection failover?

I am using NHibernate to connect to a legacy rdbms system. Under high production load the rdbms service fails. To maintain the availability we have a failover rdbms service. Is there a way to configure NHibernate to use the FailOver Connection String when the primary connection is down? Additional Info: I am using Castle over NHibernate...

nhibernate activerecord lazy collection with custom query

What i'm trying to accomplish, is having a temporal soft delete table. table Project(ID int) table ProjectActual(ProjectID int, IsActual bit, ActualAt datetime) Now is it possible to map a collection of actual projects, where project is actual when there is no record in ProjectActual.ProjectID = ID, or the last record sorted by Actual...

Using Lite Version of Entity in nHibernate Relations?

Is it a good idea to create a lighter version of an Entity in some cases just for performance reason pointing to same table but with fewer columns mapped. E.g If I have a Contact Table which has 50 Columns and in few of the related entities I might be interested in FirstName and LastName property is it a good idea to create a lightweight...

Composite primary key scenario

I need a many to many structure, but with an aggregate constraint. What i'm trying to accomplish is done easily in pure sql, but since ActiveRecord discourages composite primary keys, i'm not sure how to accomplish what i need in recommended style. Here is what i would have in pure sql: table Project (ID int) table Report (ProjectWide...

How to solve concurrency problems in ASP.NET Windows-Workflow and ActiveRecord/NHibernate?

I have found that ActiveRecord uses the Session-Scope object within the ASP.NET application and that if the web-site is read-write we can have a tug-o-war between the Workflow's own Data-Access SessionScope and that of the ASP.NET site. I would really like to have the WindowsWorkflow Runtime use the same object session as the web-site h...

Batch save in CastleProject ActiveRecord

I need to save thousand of records in a database. I am using CastleProject ActiveRecord. The cycle which stores that amount of objects works too long. Is it possible to run saving in a batch using ActiveRecord? What is recommended way to improve performance? ...

Exception "Illegal attempt to associate a collection with two open sessions" when saving object

I am using CastleProject ActiveRecord and I use lazy load feature of this ORM. In order to make lazy load work, it is required to create SessionScope. I do this in Program.cs: public static SessionScope sessionScope; private static void InitializeActiveRecord() { ActiveRecordStarter.Initialize(); sessionScope = new SessionScope(); ...

NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException

I have the following code set up in my Startup IDictionary<string, string> properties = new Dictionary<string, string>(); properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver"); properties.Add("dialect", "NHibernate.Dialect.MsSql2005Dialect"); properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Cas...

Castle MonoRail ARDataBind trying to bind to non-existent row

I have a shopping cart application running on MonoRail and using Castle ActiveRecord/NHibernate, and there is a ShoppingCart table and a ShoppingCartItems table, which are mapped to entities. Here's the scenario: a user adds things to the shopping cart, say 5 items, and goes to view the cart. The cart shows all 5 items. the user du...

Castle Activerecord. Two collections of the same class.

I want to have two collections of same class items in Activerecord. How to map this? class Project { [HasMany] IList<Resource> Resources { get; set; } [HasMany] IList<Resource> DepartmentResources { get; set; } } public class Resource { [BelongsTo ??? } ...

Castle ActiveRecord: Map to IUserType wihtin Class in C#

Hi *, for my current project I am using Castle's ActiveRecord in C#. For one of my tables I do need to use a custom type class (dealing with an stupid time to timespan conversion). To keep my code clean I like to define the class which is derived from IUserType within the object mapping class. But I can find no way to map this property ...

Failed Castle ActiveRecord TransactionScope causes future queries to be invalid

I am trying to solve an issue when using a Castle ActiveRecord TransactionScope which is rolled back. After the rollback, I am unable to query the Dog table. The "Dog.FindFirst()" line fails with "Could not perform SlicedFindAll for Dog", because it cannot insert dogMissingName. using (new SessionScope()) { try { var trans = new T...

Castle ActiveRecord: SessionScope.Current is null under IIS 7

I'm using ASP.Net MVC (still 1.0 for now) with Castle ActiveRecord and NHibernate.Linq. All is fine under IIS 6. However, I'm faced with a problem deploying my app to IIS 7: ActiveRecord's SessionScope.Current seems to be not available for some reason. Any ideas? ...

Colon ':' error - Not all named parameters have been set in Nhibernate?

I got a problem whenever I pass char ":" from the user interface. NHibernate mistakes it as a named parameter and throws an error, since there isn't any value for it. Exception is :- Not all named parameters have been set: [%] [SELECT COUNT (*) FROM Table t WHERE t.FirstName LIKE ':%' AND t.ID IN (38, 20)]" Is there any w...

Where can I download the newest Castle.Facilities.ActiveRecordIntegration.dll?

It's needed, but it's not obvious from the Castle homepage where this file sits. I am looking for a binary release, not source code. ...

Where is Castle's AbstractFacility class?

I am trying to compile Castle.Facilities.ActiveRecordIntegration with the trunk version of Castle.Core. ARIntegration uses 'AbstractFacility', which sits in the Castle.MicroKernel DLL. The DLL is now nowhere to be found. Where is ARIntegration/MicroKernel? How do I proceed? ...

Castle Active Record - Working with the cache

Hi All, im new to the Castle Active Record Pattern and Im trying to get my head around how to effectivley use cache. So what im trying to do (or want to do) is when calling the GetAll, find out if I have called it before and check the cache, else load it, but I also want to pass a bool paramter that will force the cache to clear and requ...

Castle ActiveRecord Save() will update but not create

Hello, I'm updating a program and adding a new table to the database. The program uses Castle's ActiveRecord with repositories. I've set the classes and repository up and can get the test case out of the database fine. However, when I try to add a new record to the database, nothing happens. No error and no new record. If I get the test...