fluent-nhibernate

Mapping large string with Fluent NHibernate

HI Guys, I'm working with an Oracle DB, and I'm trying to map this class: public class Book { public virtual int Id { get; private set; } public virtual string Author { get; set; } public virtual string Title { get; set; } public virtual string Text { get; set; } } With this mapping class: public class BookMap : Class...

Mapping 1 to 0..1 in Fluent NHibernate.

Lets say i have two entities; QuestionAnswer(Id, AnswerValue) Note(Id, QuestionAnswer_Id, NoteValue) How would I map this in Fluent Nhibernate? I know that there is a HasOne mapping but this is for a 1 to 1 unless im mistaken? I could also map it as a 1 to M but would require a List<Note> as a navigation property on my QuestionAnswer ...

NHibernate cascade deletes

I have a one-to-many relationship in data model from A to B. But in my domain API I do not expose "B"s on A (since we will never navigate from from A to B), but have a reference from B to A. Now I want to be able to delete all "B"s when A is deleted. Is it possible? Right now NH is trying first to set FK to null, which I don't want, and ...

NHibernate NVarchar <-> CustomClass Mapping

I have an entity which is constructed from a string and can be serialized to a string, e.g. public class EntityPart { public EntityPart(string str) { // some construction logic } public override string ToString() { // some serialization logic } } and a domain object that contains a property of this t...

Fluent NHibernate. L2 cache and lazy initialization.

All my references are configured to be lazy loaded like this: References(x => x.SomeProperty).ReadOnly().LazyLoad(); Everything works fine. Proxies are created. Now I added the following line in each entity mapping class: Cache.ReadWrite(); and enabled L2 cache like this: var fluentConfiguration = Fluently.Configure().Database(MsS...

Fluent NHibernate: Mapping a nullable value-type property as a component

How can I map a nullable value-type property as a component in NHibernate? For example: public struct PersonName { public string FirstName { get; private set; } public string LastName { get; private set; } public PersonName(string firstName, string lastName) { FirstName = firstName; LastName = lastName;...

Problems designing / mapping dynamic data-entry value store

This is tightly related to a previous question I had. It's a row/column view where columns can be several different datatypes and each row might have a value for each column. I thought of having the following structure case field fieldType bool_values fieldId caseId value int_values fieldId caseId value ...

When auto-mapping a collection with Fluent NHibernate, how do you make the child's foreign key to the parent nullable?

If I have a parent class: public class Parent { public Parent() { Children = new List<Child>(); } IList<Child> Children {get; private set;} } and a child class like so: public class Child { public SomeThirdClass Friend {get; set;} } Whenever I let the Fluent NHibernate's automapper hit these guys, it m...

Fluent Nhibernate - Map many to many dictionary with enum key

I'm trying to do a mapping for the following classes: public class A { public virtual int Id { get; private set; } public virtual IDictionary<MyEnum, B> MyBValues { get; set; } } public class B { public virtual int Id { get; private set; } } public enum MyEnum { Value1, Value2, Value3 } I'd like the resulting tables to look...

Eager Loading Using Fluent NHibernate/Nhibernate & Automapping

Hi guys, I have a requirement to load a complex object called Node...well its not that complex...it looks like follows:- A Node has a reference to EntityType which has a one to many with Property which in turn has a one to many with PorpertyListValue public class Node { public virtual int Id { get; set; } ...

Fluent mapping inheritance not by SubClass?

Hello, I have problem with mapping my classes by fluent nHibernate. My database looks look like this I have two tables Product and DocumentPossition. DocumentPossition knows about Product but product doesn't know about DP. Now on the database DocumentPossition has foreign key which is connected to Id of Product. DocumentPossition has it'...

Invalid object name 'hibernate_unique_key

I have this error when i try to save my entity: Invalid object name 'hibernate_unique_key What is the problem? With the SQL profiler i have this query: select next_hi from hibernate_unique_key with (updlock, rowlock) Can you help me? I'm using Asp.net mvc 2, Sharp Architecture (with fluent automapping) Thank you ...

Fluent nHibernate causing orphaned rows

Hi, I'm having problem with a loop which is supposed to add nHibernate objects to an existing nHibernate objects and save. There's a whole tree of relationships here there's a Page object which can have many Region objects which in turn can have many Row objects which can have many Asset objects - the problem is somewhere in the latter ...

fluent map one to many

Class Person { int ID; IList<Cat> cats; } Class Cat { int OwnerId; } how to map person cats on nhibernate fluent? probably stupid question but i cant find the answer.. thank you all. ...

NHibernate SQLquery for paging to HQL / ICriteria

Hello everyone! I'm making a query that sorts and returns X rows based on row_number() I'm using NHibernate with MSSQL and im trying to get paging working using CreateSQLQuery and i have this query: select s.* from( select distinct release.[stop], survey.SurveyId, survey.Created, survey.CopyOfId, survey.DesignTemplateId, survey.Us...

NHibernate and inheritance creating unexpected double query behavior?

I'm using FluentNHibernate. I am not using auto-mapping. I have a base class that is subclassed. When I query against the base class then it performs an extra query against the subclass. Here's the (contrived) example of what I'm doing: public class Foo { int Id; string SomeValue; } I create another class that represents a...

Team Build sends error when trying to compile a Structuremap method

Hi, I'm getting a strange error when trying to compile a solution that is using StructureMap on Team Build. When I try to compile the solution locally on Visual Studio it works fine, but when trying to queue a new build in Team Build I get the following error: Overload resolution failed because no accessible 'Use' can be called wit...

Fluent NHibernate: IEnumerable component mapping from a single query?

Hi, Hoping you can help me with a mapping problem I have. At the moment I have a view which returns something such as: Name | Title | Price | Date | Format | FormatPriority | Example data may be: Bob | Credits | 340 | 01/01/2010 | BAR | 10 | Bob | Credits | 340 | 01/01/2010 | FOO | 20 | Bob | Credits | 340 | 01/01/2010 | WOO | 40 | ...

NHibernate: Getting "Invalid column name 'ID'." when i use Criteria.List

Hi all, I'm using NHibernate with Fluent, and I'm trying to do a GetAll type thing using Critera.List: public static List<T> GetAll(int pageIndex, int pageSize) { using (ISession session = Utils.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { ...

How to map NHibernate custom collection with fluentNHibernate?

I am trying to map the collection for two days without success. I also read all possible articles and forums but still down there. Ok, here is the problem: 1) The collection class contains a private field "_internalCollection" which is mapped with NHib. 2) The holding entity should expose the collection trough readonly property. 3) I ...