fluent-nhibernate

How to have two mapping for the same table in Fluent nHibernate?

I have a User table defined like this: CREATE TABLE Users( UserId int IDENTITY(1,1) NOT NULL, UserName varchar(128) NOT NULL, Name nvarchar(200) NOT NULL, Password binary(64) NOT NULL, PasswordSalt binary(16) NOT NULL ) I'm trying to have two class that map to this table: The first object, called User has no Pass...

Fluent NHibernate - Use Stored Proc for Delete

We've implemented Fluent NHibernate, but we have a need to execute a stored proc when deleting a row for a couple of tables. Is there anyway to accomplish this without creating a command object and enlisting it with the session's transaction? ...

Nhibernate/Linq: NHibernate.QueryException : could not resolve property: Profile.class of: MyNamespace.MyObject

I'm having an issue with my linq query. I am trying to filter objects based on selected values. We use a query model which returns a System.Linq.Expressions.Expression and uses it to create an nhibernate query. Here is my linq expression. x => ( request.InitialLoad ...

Getting Fluent NHibernate To Build Database tables

I am building an app with ASP.NET MVC2, Fluent NHibernate, StructureMap, and PostgreSQL. I am a total newbie when it comes to Fluent NHibernate. I got a setup going from a couple different sources but when I build and run my app it doesnt create the database tables for the database in my connection string. I have code in a few different ...

NHibernate - Composite entity, joining table mapped by another entity.

I have the following tables: A -- Id : int SomeString : varchar(20) B -- Id : int BString: nvarchar(10) AId : int // FK to A I have an entity A which is already mapped to the table A. For the entity B, I'm trying to do a composite so that I have all the data from B, as well as the fields from A. The fields from A shouldn't be cha...

NHibernate On Legacy Database How To Tell NHibernate Which Is The Parent Table

I have two tables in a legacy database... tblParentTable (int id, string specialIdentifier, ...) tblChildTable (int id, string specialIdentifier, ...) As you can see, an auto-incrementing int id has been added, but the child table is joined using the old string primary key (in fact, specialIdentifier is the primary key of tblParentTab...

NHibertnate mapping HasManyToMany results in CROSS JOIN

Hi, I'm trying to add a mapping to the table IdentityGroup which has ManyToMany IdentityUsers thought the table IdentityGroupIdentitiy. However when I add the mapping. The result seems to be a something like a cross join. Expected result for a group with two users: Group 1: User 1 User 2 Current result for a group with two u...

Fluent NHibernate Inheritance Issue

Hello, I'm using Nhibernate with Fluent and I encounter an issue with inheritance. Here my DB schema TABLE Base IDBASE (PK) Field1 TYPE TABLE T1 IDBASE (PK and FK) Field2 Field3 ... My mapping files are : public class BaseMap: ClassMap<BASE> { public BaseMap() { Id(x => x.Id, "IDBASE").GeneratedBy.Identity(); ...

NHibernate Simple Delete Driving Me Mad

Hi, I'm trying to delete an entity (ForumTopic) and have that delete the Posts (ForumPost) within it. Here are my entities: public class ForumTopic { public virtual int TopicID { get; set; } public virtual IList<ForumPost> Posts { get; private set; } ... public ForumTopic() { Posts = new List<ForumPost>();...

Deleting a many-to-many relationship results in a delete and an insert queries

Hello all, I have an entity called Strategy, and another one called Team. Both are mapped using a Many-To-Many relationship: public class Team : BaseEntity<Team> { private readonly IList<Strategy> allStrategies = new List<Strategy>(); public void AddStrategy(Strategy strategy) { allStrategies.Add(strategy); ...

Automapping SQL Server timestamp columns to byte[] using Fluent nHibernate

I am starting to use Fluent nHibernate on a project and am trying to get the automapping to work. At the time I am stuck with the mapping of our database's timestamp fields into byte-arrays. We are using SQL Server 2008 as the database, and we are not generating the database from code. What I have: public class Entity { publi...

Fluent Nhibernate with SQL Compact: Schema Issue

Good evening people, I have been using Fluent Nhibernate for a while, I've never really dug too deep into its functionality or the many ways it can be configured. In every project I have used it in I have configure it as follows: if (nhConfig == null) { nhConfig = new NHibernate.Cfg.Configuration(); ...

FluentNHibernate One-To-One using a ForeignKey constraint.

Ok I have 2 objects and a foreign key. The first object is. public class OutboundEmailMap : ClassMap<OutboundEmail> { public OutboundEmailMap() { Table("OutboundEmail"); Id(x => x.Id, "OutboundEmailId") .UnsavedValue(0) .GeneratedBy.Identity(); Map(x => x.OutboundEmailGuid...

NHibernate SQLite on Mono concurrency problem: Database file is locked

I have an application I'm porting from MSSQL and .NET to SQLite and Mono. I'm using NHibernate, FluentNHibernate, NHibernateLINQ and SQLite. When I test the application with only one person connected everything works OK, but the moment somebody else starts using the app it breaks and throws an SQLite Exception saying "Database File is ...

how to map interface type member in a class using fluent nhibernate Automapping

how to map a class property variable of interface using automapping..is there a convention of some sort that i shoud add or override public interface Iface1 { int id {get;set;} string Name {get; set;} } public class class1 { public virtual Iface1 myIface } ...

how to tell flunet-nhibernate to use the ID from a base class (which is abstract and ignored in the mapping)

hi every one, i have an abstract class public abstract class Document { public int DocumentID {get; set;} } and derived class public class DoctorDocument : Document{ public string DoctorName {get;set;} } and I'm using Fluent Auto Mapping, i need not to make a table for Document, but i need each derived class to get the Document...

Fluent NHibernate Mapping Error

I am getting the following error using Fluent: 12:16:47,879 ERROR [ 7] Configuration [(null)]- An association from the table Address refers to an unmapped class: System.Int32 NHibernate.MappingException: An association from the table Address refers to an unmapped class: System.Int32 public class Address { p...

Fluent NHibernate Console App

I Have the Following Code in a VERY small Console App: using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using NHibernate; namespace test { class Program { static void Main(string[] args) { ...

Fluent Error Invalid object name 'hibernate_unique_key'

When I Can pull data from my table fine but when I attempt to 'VerifyTheMappings' Fluent I get an error of "hibernate_unique_key" If I turn on the SQL profiler I see the following query being run: select next_hi from hibernate_unique_key with (updlock, rowlock) Which will blow up. Is there something Special you need to do to set up H...

FluentNHibernate and VARCHAR Columns

Hi everyone, I am starting a simple .NET project with FluentNhibernate. I've followed few examples I've found on the Internet and it seems quite easy to grasp. I've realized that if I let FluentNhibernate build my DB schema (Sql Server 2000) it generates NVARCHAR fields for my strings model properties. Someone suggested that I can add ...