nhibernate

one to many / many to one nhibernate mapping..

hey hi have you find out your problem regarding the customer and employer nhibernate mapping I have the same problem for mapping article table and art_article_table both tables contain same column ids. this is art_article_table article_id esp_summary_point_id art_esp_summary_point_text 3943 2 sometext1...

Add condition to linq query

I'm building a repository layer for nhibernate, in which I have the following find method: public IList<TEntity> Find(Expression<Func<TEntity, bool>> query) I would like to add a condition to the query in that method. The extra condition should limit rows to all where RemovedAt is larger than DateTime.Now. Explanation using SQL: Le...

Castle Active Record Multiple Database Connections (Oracle and SQL)

Scenario: I have an application that pulls data from a SQL database as well as an Oracle database. I have NHibernate implemented for the SQL side and a co-worker already has a working implementation of the Oracle side (same object different project). I am currently defining a connection string in App.Config and calling this function in P...

Ria Services not populating complex properties on the client side.

I am trying to use NHibernate with RIA Services. Currently I have two entities: public class Person{ [Key] public virtual int Id {get; set;} [Include] [Association("CurrentEmployer", "CurrentEmployerId", "Id", IsForeignKey = true)] public virtual Employer CurrentEmployer { get;set;} public virtual int? CurrentEmp...

NHibernate - How to Iterate Persistent Entities Attached to a Session?

I have a need to inspect the set of attached entities that would be persisted if I called Flush() on a given session. (I'm writing code that accesses a Session as part of a generic pipeline before saving and it can be used in any number of contexts.) I find myself wishing that there were a method like mySession.GetPersistentEntities()...

NHibernate - Must Change the Save Order to Satisfy Database Constraints?

Someone on our data team added a database constraint and, while it's perfectly valid and desirable, it creates great problems for NHibernate because there doesn't seem to be a way to override NHibernate's save order. Given a (silly example) class like this: public Person { public virtual string FirstName { get; set; } public vi...

Running NHibernate queries without joining

I have Fluent mappings that maps a fictional class Customer to a list of Orders. Now I want to fetch all Customers from the database without loading Orders. Can this be specified somehow in the query/criterion/etc, or is LazyLoading the only solution? Fictional classes: public class Customer { public virtual int Id { get; set; } ...

Avoid serializing certain properties in REST services

I have a .Net application split in client and server sides, and the server provides REST services (using WCF). I have services definitions like these: [WebGet(UriTemplate = "/Customers/{id}")] Customer GetCustomerById(string id); [WebGet(UriTemplate = "/Customers")] List<Customer> GetAllCustomers(); The Customer class and its friend...

Detecting W3WP CPU issues using jetBrains dotTrace

Hi, Our W3WP process on our production server is constantly high. It doesn't max out at 100% but jumps up into the 90%s a fair bit. To help look into this I profiled the live aplication using JetBrains dotTrace. The results were as expected. All the slow methods were NHibernate functions that queried our database. My question is, would...

What is the difference between SaveOrUpdateCopy and SaveOrUpdate in Nhibernate?

Hi Let me know the difference between SaveOrUpdateCopy and SaveOrUpdate method in NHibernate. Regards KJCreddy. ...

Fluent nhibernate : HasManyToMany mapping exception

Hello everybody. I'm having issue when I use Fluent nHibernate for mapping entities with my SQL database. To understand the problem, here is an example. This example modelizes via SQL tables a mail box, that allows users to put their mail in one or many folder (like the label system in gmail). // contains every users USER ( Id (b...

FluentNHibernate Where clause does not appear to be used when populating collections

I use a Where clause in my FluentNHibernate mappings as follows: public class FooMap : ClassMap<Foo> { public FooMap() { Table("MySchema.Foos"); Where("Deleted = 0"); etc etc } } This where clause gets appended to the SQL when I load individual Foo instances through session.Load<Foo>(1) and when I use LINQ queries. H...

Spring.net TransactionPropagation NotSupported

Hello, I'm in troubles with TransactionPropagation.NotSupported. I believed that this propagation causes that the code is executed within no transaction. Means that when I marked the specific method, the current transaction will be suspended and the code will be executed without any transaction. The current version of spring.net create...

Where to put object-oriented queries in a layered architecture?

Given: You have an architecture with the layers presentation, business and data. You are applying domain-driven design. You are using an object-relational mapper that lets you create object-oriented queries (e.g., NHibernate which lets you create HQL queries). Question: Into which layer should you put the object-oriented queries? M...

NHibernate.Linq count throws NHibernate.QueryException : could not resolve property

I'm building an ecommerce site using S#arp Architecture. I'm trying to map a hierachy of categories and retrieve the top level categories. I'm using NHibernate.Linq for this. I have the following entity: public class Category : Entity { #region Properties [DomainSignature] [NotNullNotEmpty] public virtual string Name {...

NHibernate Projections Duplicates To List

I have a problem with nHibernate projections. I don't even know if what I'm attempting can be done but if any nHibernate experts can help me I'd be grateful. I'm using nHibernate criteria to query a database and I'm returning the result projected to a different (slimmed down) object. I get a list of returns like Id CompanyId Descr...

NHibernate.LINQ Supported Operators

I'm trying to evaluate NHibernate.LINQ 1.0 without actually writing any code. Ayende has admitted that this version of LINQ support is subpar compared to EF, but for the life of me I can't seem to find a page that explains what's supported and unsupported in this implementation. For example, can I use Skip & Take? What can I not use? ...

How to model this classes withN Hibernate and Fluent.NHibernate Maps?

Hi. I'm using ASP.NET MVC with NHibernate and Fluent.NHibernate Maps. I would like to know how to map the classes on Fluent and to create the database tables on my MySQL: public class AgenteDeViagem { public virtual int Id { get; set; } public virtual string Email { get; set; } public virtual AgentePessoa AgentePessoa { ge...

NHibernate and Raw ADO.NET usage

Background: I am using Nhibernate in an ASP.NET MVC application with an open-session-in-view pattern and I need to use raw ADO.NET to execute some performance-critical database operations. I'm somewhat confused about how I should be getting my connection instance as I've seen two different methods in numerous blog posts. Do I want to u...

How do I unit test protected properties meant to be set only by NHibernate?

I'm using NHibernate to persist this entity: public class Store { public int Id { get; protected set; } public int Name { get; set; } } Note how the Id property has a protected setter. This is to prevent users from changing the Id while still allowing NHibernate to assign it an Id when it saves it to the database. In one of m...