nhibernate

Strategy for migrating to NHibernate

Hi, I have a homebrew "ORM" solution that I want to migrate to nhibernate, but I can't seem to find a solution to the inheritence mapping I use and a matching one i NH. Here is what my current solution looks like: Example one to many: Type1 "1 - *" Type2 Type2 - Type1Id If there is inheritance on Type1 then in Type2 I have a seco...

Creating NONCLUSTERED INDEX on column by convention or fluent map

Hi, I want to use schemaExport to generate my Database. So, I would like some help as one of my table needs to have a non-clustered index on one column. Is there any way I can use the IIndexConvention to implement it? I could use a custom attribute to distinguee the property and then apply the convention for example. Many thanks. ...

NHibernate + Fluent long startup time

Hi all, am new to NHibernate. When performing below test took 11.2 seconds (debug mode) i am seeing this large startup time in all my tests (basically creating the first session takes a ton of time) setup = Windows 2003 SP2 / Oracle10gR2 latest CPU / ODP.net 2.111.7.20 / FNH 1.0.0.636 / NHibernate 2.1.2.4000 / NUnit 2.5.2.9222 /...

Stateless NHibernate for querying

We have a database that is updated via a background process. We are using NHibernate to query the data for display on the web UI, so we don't need change tracking or lazy-loading. If we mark all the mappings as mutable="false", is this the same as using a stateless session? ...

LIKE query for DateTime in NHibernate

For a column of type varchar I could write such a query: public IList<Order> GetByName(string orderName) { using (ISession session = NHibernateHelper.OpenSession()) { return session.CreateCriteria<Order>(). Add(Restrictions.Like("Name", string.Format("%{0}%", orderName))). List<Order>(); } } How do I write a similar LIKE-qu...

NHibernate query CreateCriteria

Is it possible to chose what columns I want in return from Session.CreateCriteria() ? egz.: var x = session.CreateCriteria(); x.CreateAlias("EmployeePosition", "employeePosition"); x.Add(Restrictions.Eq("employeePosition.Name", "Developer")); and is there a way to add something like "select LastName" to avoid downloading the ...

NHibernate Mapping problem

My database is being driven by my NHibernate mapping files. I have a Category class that looks like the following : public class Category { public Category() : this("") { } public Category(string name) { Name = name; SubCategories = new List<Category>(); Products = new HashSet<Produ...

NHibernate WCF Bidirectional and Lazy loading

Hi everyone, I'm just looking for some direction when it comes to NHibernate and WCF. At the moment i have a many to one association between a person and address. The first problem. I have to eager load the list of addresses so it doesn't generate a lazy loaded proxy. Is there a way to disable lazy loading completely? I never want ...

Nhibernate beginner - asking for directions

Hello guys. I'm starting off with NHibernate now and I still don't have a testable environment. I would like to know from you, experienced fellows if there is a problem to map IList to an Set in .hbm file. Like this: //c# IList<TrechoItem> trechos_item; <!-- xml .hbm --> <set name="TrechosItem" table="trecho_item" lazy="true" invers...

Noob question: How to make a criteria on the count of an association?

I'm starting with NHibernate. I have a type called Person which has a collection of Address. How do I fetch: All people with at least 2 addresses using ICriteria? Thanks in advance. ...

Bidirectional one-to-many associations with indexed collections in NHibernate

Last summer, I asked a question regarding how to add new object to an IList mapped as a one-to-many with NHibernate. One of the answers let me to this paragraph in the documentation: Please note that NHibernate does not support bidirectional one-to-many associations with an indexed collection (list, map or array) as the "many" end, y...

Fluent NHibernate Automapping with RIA services

Hi guys I've encountered a slight problem recently, or rather a lack of understanding of how NHibernate automapping works with RIA data services. Namely, I don't understand how to use Association and Include attributes. For instance, I've created two tables in my database and corresponding classes (that NHibernate correctly fills). The...

NHibernate: update item in list from an Interceptor

hi When i try to update a property on a item that is in a list from an interceptor, the update is not persisted. Is this possible at all? or am i doing something wrong? The child is mapped as a list of composite elements. The context is, i am trying to enforce read consistency for aggregates using Read committed isolation level and ...

How to Specify Columntype in fluent nHibernate?

I have a class CaptionItem public class CaptionItem { public virtual int SystemId { get; set; } public virtual int Version { get; set; } protected internal virtual IDictionary<string, string> CaptionValues {get; private set;} } I am using following code for nHibernate mapping Id(x => x.SystemId); ...

NHibernate Native SQL and DialectScope

Hi, I have two native SQL queries. One for Oracle and one for MSSql. I want to run them trough NHibernate. How do I find out what Db-engine I'm on? I know I can add dialect-scope in mapping files for <database-object />. Is there something similar for <sql-query />? Or should I put an if-loop in my code and try to figure out the dialect...

How is Entity Framework 4's POCO support compared to NHibernate?

Just wondering if anyone has had any experience using Entity Framework 4's POCO support and how it stands up compared to NHibernate. If they're the same, I'd be very interested in making Entity Framework 4 my ORM of choice if only because it would: Support both data first AND object first development Have a robust LINQ provider Be easi...

NHibernate: Mapping different dynamic components based on a discriminator

My domain entities each have a set of "fixed" properties and a set of "dynamic" properties which can be added at runtime. I handle this by using NHibernate's dynamic-component functionality. public class Product { public virtual Guid Id { get; } public virtual string Name { get; set;} public virtual IDictionary DynamicComponents ...

How do you compare using .NET types in an NHibernate ICriteria query for an ICompositeUserType?

I have an answered StackOverflow question about how to combine to legacy CHAR database date and time fields into one .NET DateTime property in my POCO here (thanks much Berryl!). Now i am trying to get a custom ICritera query to work against that very DateTime property to no avail. here's my query: ICriteria criteria = Session.Cr...

SQLite NHibernate configuration with .Net 4.0 and vs 2010

UPDATE In the last update I could use SQLite for unit testing but not in an application run. That problem has now been resolved by modifying config to allow [loading from a remote assembly](http://msdn.microsoft.com/en-us/library/dd409252(VS.100.aspx) <runtime> <loadFromRemoteSources enabled="true"/> </runtime> in addition to ena...

Does Castle ActiveRecord's ActiveRecordMediator<> support LINQ?

Does Castle ActiveRecord's ActiveRecordMediator<> class support LINQ queries? I couldn't find any method that returns an IQueryable<>. My domain objects can't inherit from ActiveRecordLinqBase<> due to their design. ...