nhibernate

How to filter a list of Groups that don't contain Companies?

I'm currently getting a list of Groups as follows: var groups = _session.CreateCriteria<CompanyGroupInfo>() //.SetProjection(Projections.ProjectionList() // .Add(LambdaProjection.Count<Company>(c => c.Id) > 0)) .AddNameSearchCriteria<CompanyGroupInfo>(searchExpression) .AddOrder<CompanyGroupInfo>(e => e.Name, Order.As...

NHibernate Equals and GetHashCode

Why do I need to override Equals and GetHash code in my Entities when using NHibernate? Today I got this error System.ApplicationException : For property 'Person' expected 'Domain.Person' of type 'Domain.Person' but got 'PersonProxy20252a6926f841a8b45e327292fe0eae' of type 'Domain.Person' Now I have read(but not confirmed) that This i...

How to use NHibernate and DTOs with RIA Services

I’m using NHibernate with RIA Services and Silverlight 4. I create DTOs for transferring the data via RIA Services rather than distributing my domain layer objects (as per Martin Fowler’s First Law of Distributed Object Design: “Don’t distribute your objects!”). The DTO objects are flattened down to two layers from five corresponding ...

Nhibernate querying collections Restrictions.In

I have 2 classes Class FruitShop { int FruitShopId; string FruitShopName; IList<Fruit> Fruits {ge;set;} } class Fruit { int FruitID {get; set;} string FruitName {get; set;} bool IsSweet {get; set;} int FruitShopId {get; set;} } I want to write an expression to return from FruitShop Table, all records, that have a recor...

NHibernate InvalidProxyTypeException

I get this NHhiberante when verifying my Fluent Mappings FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. ----> NHibernate.InvalidProxyTypeException : The follow...

Read-Only Joined Collection in NHibernate

Here is the basic situation. In our application, we have Roles and Permissions. There is a many-to-many relationship between roles and permission. The catch is, that a user can be assigned roles directly, or they can have a role that they have acquired by paying for a service. To make things more interesting, if the user cancels the ...

Domain Design and NHibernate

Given the database design below how would you model it? Address Type is Bussiness/Home etc and the PersonId is on Address table is because there are many addresses for one Person. I would most do something like: public class Person { public virtual int PersonId { get; set; } public virtual string FirstName { get; set; } publi...

Configure NHibernate to compile mappings "on the go"

By default, NHibernate compiles the mappings when creating the SessionFactory... Is it possible to configure NHibernate so that it compiles the needed mappings "on the go"? So that it only compiles a mapping when it needs it? The reason I'm asking is to work around the lenghty operation on start-up (of a winforms, well, AutoCAD applica...

Why NHibernate auto-truncates instead of throwing an exception on save?

Hi, I have been studying the Summer Of NHibernate Tutorials and when I have reached the Session 04: Exploring Transactions and Concurrency -just like in the tutorial- I wanted to create a SAVE test which should fail because of an invalid object. The purpose is to test if it can rollback the transaction properly. Idea is to create an i...

How can i perform this query in NHibernate for getting child count

select name, (select count(*) from products where products.category_Id=categories.Id) as productCount from categories session.CreateCriteria<Category>() but whats next? i don't even know how to search it in Google? ...

NHibernate notify other sessions about changes

Hello, My application consists of two views, list and detail. Every instance of view has it's own NHibernate session. When user saves entity from detail view, an event is published to the list view (entity id) after that, list view re-fetches modified entity using it's own session. In order for list view's session to get fresh versio...

how to get authenticated user id from wcf in nhibernate

Hi I have implemented NHibernate custom context (ICurrentSessionContext). In this context I inject the NHibernate session so I have Session per call pattern setup. Ok, now I have made an interceptor that takes userId of the current logged user. Now I do this: public ISession CurrentSession() { // Get the WCF InstanceContext: var con...

NHibernate - one to one relationship producing multiple queries

I have an object in my application, Item,> which has a one to one relationship to Result. The database tables are as follows: TABLE Item ItemId INT NOT NULL (PK) ResultId INT NULL (Foreign key to Result) TABLE Result ResultId INT NOT NULL (PK) ResultColumns etc ... In my mappings I have this as: <class name="Item" table=...

How can I stop Fluent NHibernate from creating foreign keys

I got a polymorphic relationship like the following example: public class A { public virtual Guid Id { get; set; } public virtual string Name { get; set; } } Class B & C contining a List of A's: public class B/C { public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual IList<A>...

"No persister for: X.Domain.Person" Nhibernate Error

in My nhibernate.cfg.xml file I have <mapping assembly="X.Domain" /> Which would usually works - Inside My X.Domain I have my Fluent Mappings. in which I have tests to verify all the mappings are set up correctly. Not sure if this is because I am using Fluent in my Domain Layer and nhiberante.cfg.xml in my MVC project. Any ideas ...

Runtime error when trying to run Fluent NHibernate tutorial example.

Hello, I worked through the Fluent NHibernate tutorial at http://wiki.fluentnhibernate.org/Getting_started and the project compiles fine. However, I am getting a runtime error and I can't seem to resolve it. The error is happening in the CreateSessionFactory method you can see in the tutorial. Here it is: private static ISession...

Perform MySql Fulltext Search using NHibernate

Is it possible to execute a statement like this in NHibernate? SELECT * FROM mytable WHERE field2 = "word" OR MATCH (field1) AGAINTS ('wordA' IN BOOLEAN MODE) ...

Nhibernate - How to Design DomainObjects and Mappings with CompositeId

Hi, at first i'm really new to ORM, nhibernate and FHN. i look into this stuff for a few days now. i have an existing database with 4 tables: so i tried first to get the Auswahl and RefAuswahlFilter to work. here are my DomainObjects: pls let me know when i can do this better [Serializable] public class Auswahl { public Auswahl...

Is it possible to handle columns as rows type design with an ORM?

I have a situation wherein to accomodate the need of dynamic addition of columns to a table, I am putting the columns values as rows in a table. As an example, storing of columns of an Address Table would be in the format: ID PropertyName 1 HouseNo. 2 Street 3 City 4 State 5 Country Now, if I need to create an O...

I get a Argumentexception by binding a customer to a WinForms Bindingsource

Hello, I'm learning NHibernate with Fluenthibernate. I'm using it with C#, Winforms and BindingSource, and I get a Argumentexception by loading a Customer without orders. What can I do or what is wrong? Mapping: public class CustomerMap : ClassMap<Customer> { public CustomerMap() { Id(x => x.Id); HasMany(x => x....