nhibernate

Using dynamic proxy on NHibernate objects

Hi, I'm trying to use Castle.DynamicProxy2 to cleanup code within NHibernate persisted classes. Here is a simple version of it. The Pet class: public class Pet { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } } And its mapping file: <class name="Pet" table="Pet"> <id name="Id...

NHibernate nested class mapping problem

I have below classes. How can I write mapping document for MainBranch.Id column. I have no branch table in database, just want to use branchId for MAINBRANCHCODE. Any Idea? public class Bundle { public virtual Decimal Id { get; set; } public virtual BundleEntranceInformation Information { get; se...

lazy loaded NHibernate collections into ViewModels?

hey folks, I have my NHibernate mappings set to lazy loading = true. In my CustomersViewModel I have something like: foreach (Customer c in _customerRepository) { this.Customers.Add(new SingleCustomerViewModel(c)); } This obviously kills all the lazy loading, since the customers are passed one by o...

nhibernate mapping question

I have a set of tables, with a .hbm.xml for each. I tried to put in a named query but it would not compile. I moved the code to a CreateQuery and get. DB_Portfolio is not mapped [select sum(p.Shares * s.Price) from DB_Portfolio p, DB_Securities s where p.AccountNumber = :accountNumber and p.CUSIP = s.Cusip] The CreateQ...

Mapping complex classes with Fluent NHibernate

How can I map a class that contains a HashMap using Fluent NHibernate? ...

nhibernate 'virtual' fields

I want to have a 'virtual' (not there, not to be confused with the virtual keyword) field in a nhibernate class. I have a securities table and I want to have a 'virtual' field that uses another field to return a flag. I have added a calculated field in the db_securities table nhibernate class: public class DB_Securities { ...

Advice re. Windows Forms application - "local" and "network" modes

Hi all, I've started to build a Windows Forms application. The application will work in two different modes: local (1 user, opening and saving files just like a Microsoft Office application) network (multiple users, all accessing a shared database in another host of the network) For the local mode I am planning to use a SQLite embed...

NHibernate and many to many mapping

Hi. I have 3 tables organization(id, name, and etc) organizationContact(organizationId, contactId, status) contact(id, name, email) How can I make a many to many mapping and use status column from organizationContact? ...

TM1 API for LinqToEntities

IBM Cognos TM1 is a multidimensional database that my company thinks is the latest and greatest. I've been to the classes and, sure, it is nice for analysis. Of course the finance people in my company only see the Excel Add-In or Excel-like website and think "that's all I need for a data entry application!" My response is "I thought you ...

Does Fluent-Hibernate exist?

Is there something like Fluent-NHibernate for the original Java Hibernate? If not, why not? Are there any language-specific limitations? ...

Group by date with LINQ to NHibernate

I am facing an issue with an unsupported feature in the LINQ implementation of NHibernate (it's firing a QueryException: "could not resolve property: CreatedOn.Date of: Example.Comment"). Given the entity below, I would like to extract statistics by grouping the comments per day and sum up the amount of comments for each day (naturally ...

Correct NHibernate mapping for a specific scenario (one-to-many/one-to-one)

I had a following structure: User has many books in his history which was translated to the following class User { ICollection<Book> History } // C# User -> UserHistory (UserId, BookId) -> Book // DB Now I want to add a date to the history, creating the following class structure: class User { ICollection<Read> History } ...

FluentNHibernate - AutoMappings producing incorrect one-to-many column key

Hi I'm new to NHibernate and FNH and am trying to map these simple classes by using FluentNHibernate AutoMappings feature: public class TVShow : Entity { public virtual string Title { get; set;} public virtual ICollection<Season> Seasons { get; protected set; } public TVShow() { Seasons = new HashedSet<Season>...

Join between two non-key fields

I'm working on putting together a simple POC app using Fluent NHibernate to attempt to show that it can do everything our current hand-rolled data access tool and so much more. One of the fringe cases that my boss is worried about is the ability to access multiple schemas within the same database in one query. So far I have been able to ...

NHibernate & Linq - "could not resolve property"

Mapping-File: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DaVinci" namespace="DaVinci.Domain"> <class name="Waehrungskurs" table="WAEHRUNGSKURSE"> <id name="Id" column="ID"> <generator class="native" /> </id> <property name="ISO...

Implementing repositories using NHibernate and Spring.Net

I'm trying to get to grips with NHibernate, Fluent NHibernate and Spring. Following domain-driven design principals, I'm writing a standard tiered web application composed of: a presentation tier (ASP.Net) a business tier, comprising: an application tier (basically a set of methods made visible to UI tier) repository interfaces and d...

What's the most productive way to do NHibernate mapping?

I know annotations to do the hibernate mapping in Java and am looking now for a similar way to do the same in C# and NHibernate. I found out that there exists several approaches do the mapping in xml files NHibernate.Mapping.Attributes (NHMA) Fluent are there any more?? I tried NHMA and found out it had some blocking points for me......

NHibernate HQL Group by Entity

Is it possible to run a query similar to this one in HQL without having to specify all of the column names. select med, MAX(med.PrescriptionLines.Prescription.PrescriptionDate) from Medication med where med.Patient.PatientId = :patientId group by med This query expands out all of the properties of the Medication object in ...

Nhibernate change from lazy=false to fetch=join many-to-many

i have: <bag name="Categories" table="CMS_Articles_Categories" lazy="true"> <key column="article_id"/> <many-to-many class="Framework.CMS.Domain.Category, Framework.CMS" column="category_id"/> </bag> This is under an Article mapping. An article can be in many categories and of course a category has many articles. When this is ...

Peculiar scenario for loading child objects using nHibernate

Hi guys, I've got a "weird" scenario in an app I'm writting, and trying to get to grips on ow I can implement using nHibernate. The scenario goes like this ... there is a Test. A Test is made up of a series of Testlets ( a Testlet is a set of pre-defined questions, with metadata ... ). The thing ... while I'm running the test, the ...