fluent-nhibernate

Fluent Nhibernate - dont understand the generated Sql from NHibernate

hi, i created the following mappings with fluent nhibernate: public class AuswahlMap : ClassMap<Auswahl> { public AuswahlMap() { Table("AUSWAHL"); Id(x => x.Id,"ID") .GeneratedBy.Sequence("SEQ_AUSWAHL"); Map(x => x.Programm).Not.Nullable();; Map(x => x.Variante); Map(x => x...

Fluent HNibernate Mapping Property Issue

Hi, i have two entities one called User and another called Membership which has a one to many mapping from User to Membership. I need to add a property on my User entity called CurrentMembership which gets the latest Membership row (ordered by the property DateAdded on the Membership Entity). I'd appreciate it if someone could show me ...

Fluent NHibernate Mapping Single Column to Composite Key

Hi All, I have a situation where i have defined an entity in my domain model in which I would like to expose a single id column. public class OfferedProduct { public virtual string Id {get; set;} //other properties } The legacy database table this will map to is CREATE TABLE ProductGrouping MemberNumber INT NOT NULL...

Fluent nHibernate Automapping not creating Plural table name

I have two tables, Locations and Facilities They map to two classes, public Location : Entity { //properties } public Facility : Entity { public virtual Location Location { get; set; } } Everything works just dandy, until I change facility to this public Facility : Location { } Now I get an exception from nHibernate sayi...

NHibernate - Delete Not Peristing in the Database

Hi, i'm trying to remove an item from a one to many list and have it persist in the database. Here are the entities i have defined: public class SpecialOffer { public virtual int SpecialOfferID { get; set; } public virtual string Title { get; set; } public virtual IList<SpecialOfferType> Types { get; private set; } pub...

I cannot figure out what I'm doing wrong with this basic NHibernate query...

Okay, I have a class, Company public class Company { public virtual int Id { get; set; } public virtual IList<Role> Roles { get; set; } } And another class, Role public class Role { public virtual int Id { get; set; } public virtual Company Company { get; set; } public virtual RoleLevel RoleLevel { get; set; } } ...

SQL to NHibernate Criteria Query

Hi, I'm using Sharp Architecture for an MVC application and I'm trying to generate a nhibernate criterion query for the following SQL: select top 10 p.* from Tab1 p join Tab2 v on p.Id = v.Tab1Fk join Tab3 sbu on v.Id = sbu.Tab2Fk where sbu.DateTime >= 12/12/2002 00:00:00 ...

Fluent NHibernate - Collections not filtering

I have a session criteria statement (Fluent NHibernate) that does not seem to filter the child collection even though I have Expressions/Restrictions defined. ICriteria criteria = session.CreateCriteria(typeof(MyClass)); criteria.CreateAlias("MyCollection", "MC"); criteria.Add(Restriction.Eq("MC.Property", value)); IList<MyClass> list =...

Mapping a property to an index column

I'm trying to map a List with an index column. This works fine, but i would also like to be able to query the index column from HQL. When i do that HQL throws an exception: NHibernate.QueryException: could not resolve property: Position of: component[Location,Time] To be able to query the WayPoint.Position column from HQL, i have creat...

Fluent Nhibernate: Mapping single entity with interface requirements

Good afternoon. Before I begin my explanation, I have had a look at other similar questions but the subtle differences (mainly in purpose of design) mean that the solutions provided in these answers to not apply to me. I am attempting to create a 'Base data access library' for use with future projects so that I do not have to spend my ...

How to represent next nhibernate xml in fluent-nhibernate?

How to represent next nhibernate xml in fluent-nhibernate? <set name="Items" lazy="true" table="CATEGORY_ITEMS"> <key column="CATEGORY_ID"/> <composite-element class="CategorizedItem"> <parent name="Category"/> <many-to-one name="Item" class="Item" column="ITEM_ID" ...

Fluent Nhibernate - How do I set the name attribute of a set or bag collection?

This is a set collection: <set access="field.camelcase-underscore" cascade="save-update" inverse="true" lazy="true" name="employees" table="TeamEmployee" mutable="true"> How do I set the name attribute? ...

Fluent NHibernate and automapping generic types

Hi, I'm automapping most of my model, but have a problem with generics. I've got ValueContainer, and I make it abstract so that it doesn't throw an exception during automapping. Next, I have to create classes like StringValueContainer just to make it mapped. Needless to say, I don't like this approach, since I'm perfectly happy with the...

fluent nhibernate automap inferring incorrect key

Hello, I am having trouble using CreateCriteria to add an outer join to a criteria query while using Fluent NHibernate with automapping. Here are my entities - public class Table1 : Entity { virtual public int tb1_id { get; set; } virtual public DateTime tb1_date_filed { get; set; } . . . virtua...

Fluent NHibernate 1.1 stored procedure question

Hi I'm executing a stored procedure with NHibernate. My mapping file is below. Fluent NHibernate for some reason is placing the Id column as the last parameter of the stored procedure. I need it to be the first parameter of the proc. You can see in the log how it is mapping the value 130 to parameter 23? Anyone know if this is a bug...

Fluent NHibernate: Column mapping convention

I'm having some problems with getting the following convention to work: public class ColumnNameUpperConvention : IPropertyConvention { public void Apply(IPropertyInstance instance) { string cName = instance.Property.Name.ToUpper(); instance.Column(cName); } } What I'm wanting the above code to do ...

Abstract property inheritance and Fluent NHibernate Automapping

I thought I understood what I was doing, and I swear this used to work when I used it in my last project! I have an abstract class Enity that I use as a base class for all my DomainModel classes when working with NHibernate. The class is defined as: public abstract class Entity<TKey> where TKey : IComparable { public abstract TK...

NHibernate cascade and inverse

I have three mappings as follows: public MainChapterMap() { // other properties HasMany(x => x.ClientSpecific).KeyColumn("MainChapterId"); } public MainChapterClientMap() { // other properties References(x => x.MainChapter).Column("MainChapterId"); HasMany(x => x.Details).KeyColumn("MainChapterClientId"); } publi...

nhibernate query all objects implementing an interface

For example, if you have an Apple : IWhatever, and an Orange : IWhatever and you want to find both of them because they are IWhatevers, what do you need to do in NHibernate? Is it completely dependent on the HQL or criteria query, or is there something you must do in the mapping also? If there is a mapping requirement, can Fluent NHiber...

What is the purpose Fluent NHiberate's KeyUpdate mehod?

I have a collection mapped as a query only property following Ayende's example. My mapping is: HasMany<Employee>(Reveal.Member<Company>("_employees")).Access.None(); This worked fine, except when I load a Company the foreign key Employee.CompanyId is updated to null. This occurs even if I don't update Company and the generated SQL onl...