nhibernate

Where to get Rhino Commons

Hi I'm working on an asp.net mvc project using nhibernate. At the moment I think Rhino Commons session management is the best spproach to control isession. But Where should I get Rhino Commons From? I found it located on Horn, Github, think the svn is obsolete. Please point me to a version that works. ...

Mapping lookup table to class

I have a reference/lookup table whose main purpose is to provide the user with a list of existing options. The user will also have the ability to enter new items into the list. How would you map this in NHibernate? For example, say I have an Address class with a City field. The database has an Address table and a City lookup table. ...

Open/Close NHibernate Session

Using FluentNHibernate in a web application, I've created a singleton SessionFactory class to have the ability of the following: SessionFactory.Instance //returns ISessionFactory Is it common/best practice to open/close sessions as follows? using(ISession session = SessionFactory.Instance.OpenSession()) { using(ITransaction trans...

NHibernate MappingException. No Persister.

I'm trying to get NHibernate to work. I've got this class: mm.k.Domain.Kampagne (namespace/assembly is mm.k.Domain) In another Visual Studio project (Assembly mm.k.Infrastructure) I got my Mapping files (in a Mappings directory), my hibernate.cfg.xml and some repositories. Heres my mapping file: <?xml version="1.0" encoding="utf-8"...

NHibernate: Convert Guid to string in query

Using NHibernate with Linq or Criterion, is it possible to do a LIKE query on a GUID column? In T-SQL this is easy: *select * from mytable where id like '0ae%'* NHibernate won't convert the Guid to a string though. ...

NHibernate filter collection

Using NHibernate I want to filter a collection in a class to contain ONLY a subset of possible objects. Below I am including a sample table data to help explain. I can find no way to do this using NHibernate. Table:DataObject DataObjectId(PK) / Name / CurrentVersion 11 "data.txt" 2 12 "info.txt" 3 Table...

Nhibernate: one-to-many, based on multiple keys?

Lets assume I have two tables Table tA ID ID2 SomeColumns Table tB ID ID2 SomeOtherColumns I am looking to create a Object let's call it ObjectA (based on tA), that will have a one-to-many relationship to ObjectB (based on tB). In my example however, I need to use the combination of ID and ID2 as the foreign key....

NHibernate - Getting the results as an IDictionary instead of IList

Hello, I'm using NHibernate as a persistency layer and I have many places in my code where I need to retrieve all the columns of a specific table (to show in a grid for example) but i also need a fast way to get specific item from this collection. The ICriteria API let me get the query result either as a unique value of T or a IList of...

Can I create an many to many mapping with Fluent NHibernate with a primary key?

I am trying to implement a post tagging systems into my Blog and decided to attempt to implement the Toxi solution from here: http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html. I currently have two POCO classes designed. One for Post and one for Tag public class Post { public int ID { get; set; } ...

set int column in DB to null

Hi, I'm looking for a point in the right direction to solving this problem. I am being passed an object from the ui. One of the values is for a foreign key (an int which allows nulls). The value being sent is -1 which signifies that the value has not been set by the user. How can I write this object to the db setting the foreign key ...

Previewing the sql code generated by NHibernate

Using NHibernate 2.0: I have an object with some changes on it and I am about to session.Update() it. Is there some way I can preview the SQL that will be executed without actually executing it? ...

NHibernate: hql to criteria query - help needed

Hello there, I have this hql query, which works perfect: select m from Media m join m.Productlines p join m.Categories c join m.Spaces sp join m.Solutions so where m.Uid != 0 and p.Uid in (:productlines) and c...

NHibernate: Could not create the driver from Test.SqlServerCeDriver_ImageFix.

Im trying to resolve an issue where when using NHibernate with a SqlServerCeDriver that uses an image column you receive an error: "Byte array truncation to a length of 8000.". I found the following solution: http://mgeorge-notes.blogspot.com/2009/05/nhibernate-mapping-from-binary-to.html And created the following class: namespace Tes...

FluentNHibernate - ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore)

Can anybody confirm that this does not work as expected, as I am getting an error that it is trying to access property rather then trying to access field. private IList<MetaPackage> _metaPackages; public virtual IEnumerable<MetaPackage> MetaPackages { get { return _metaPackages; } } Fluent mapping HasMany<MetaPackage>(x =...

NHibernate - need help with ICriteria query

I am having trouble getting my query by criteria to work. I want to filter the UserPublications collection by userId but it is not filtering. The ClientPublications collection has filtered correctly though. Any advice? Thanks in advance. public IList<ClientReport> GetAvailableClientReports(int userId) { ICriteria criteria...

NHibernate.Linq LockMode

Is it possible to set the LockMode when using NHibernate.Linq? When using ICriteria I can this way: var criteria = Session.CreateCriteria<Foo>(); criteria.SetLockMode(LockMode.None); criteria.Add(Expression.Eq("Title", title)); Is it possible to build that same query using Nhibernate.Linq? ...

Flushing in NHibernate

This question is a bit of a dupe, but I still don't understand the best way to handle flushing. I am migrating an existing code base, which contains a lot of code like the following: private void btnSave_Click() { SaveForm(); ReloadList(); } private void SaveForm() { var foo = FooRepository.Get(_editingFooId); foo.N...

HQL to CriteriaQuery conversion

Class is defined as this: class User { public int ID { get; set; } public string OpenID { get; set; } public IList<Tag> Tags { get; set; } } OpenID is set as natural-id, so that the second level cache recognizes this. I have this HQL query which returns a list of user tags. db.CreateQuery("select Tags from User where ...

Fluent NHibernate - SessionSource and PersistenceSpecification

Hi to FNH peeps, 1) Could anyone give a clear explaination of what SessionSource is intended for, and why would I want to use this rather than just Fluently.Configure()....BuildSessionFactory()? 2) What is the PersistenceSpecification class for? I know you can use it for persistence testing (http://wiki.fluentnhibernate.org/Persistenc...

Select unsaved object out of the session

Hi, Using NHibernate 2.1 on mssql with C#. I have 2 diffrent classes witch use an "group" object. <class name="OrderCode" table="OrderCode" polymorphism="explicit"> <id name="Id" column="ID"> <generator class="native" /> </id> ... <many-to-one class="Group" name="Group" column="GRUPPE" cascade="all" /> ... and <class name="Alot...