fluent-nhibernate

Fluent NHibernate Joined-Subclass Problems

I have this class public class Address:Entity { public virtual string Address1 { get; set; } public virtual string Address2 { get; set; } public virtual string City { get; set; } public virtual string State { get; set; } public virtual string Zip { get; set; } public virtual string Phone { get; set; } public ...

AutoMapping a Composite Element in Fluent Nhibernate

I'm trying to get the AutoPersistence model to map several composite elements. However, it seems that either I end up mapping it as an entity, dropping down to manual mapping or it just doesn't plain work. Here's some code that demonstrates my problem: using System; using System.Collections.Generic; using FluentNHibernate.AutoMap; usi...

database in App_Data not persisting data

I have a a sql database in my app_data folder and my connection string looks like this: Server=.\SQLExpress;AttachDbFilename=|DataDirectory|wikipediamaze.mdf; Trusted_Connection=Yes; I'm using Fluent Nhibernate, and everything is mapped properly. I'm able to connect to the database fine and even update and insert rows with no problem. ...

NHibernate - LazyLoad one-to-zero

Hi Iam struggling with NHibernate and its lazyload. I have a structure which I simplified but it show my issue. Class Shift { int ShiftID; DateTime ShiftStart; Employee Employee; } Class Employee { int EmployeeID; string Name; } Data: ShiftData ID SHIFTTIME EmployeeID (int) 1 ...

How to map a foreign key column in nhibernate?

Actually, the question is more complex than as it is described. I am newbie on nhibernate and I want to map a table with foreign key columns. In most of nhibernate samples the foreign key column assignments are generally implemented by setting the referred entity. I mean, If I have a CategoryId column then I need a Category property and ...

Fluent NHibernate Automapping: Alter DateTime to Timestamp

Hello, I am getting (a little bit to) deep into automapping with the fluent interface of NHibernate. Very nice thing, but I ran into a little problem with DateTimes. I need to change the data format to timestamp, otherwise NHibernate truncates milliseconds. I found several sources of information, the best one was: AutoMapping Info 1 whe...

NHibernate ICriteria query with components and collections for advanced search

I'm building an advanced search form for my ASP.NET MVC app. I have a Customer object, with an Address Component: Fluent NHibernate mapping: public CustomerMap() { WithTable("Customers"); Id(x => x.Id) .WithUnsavedValue(0) .GeneratedBy.Identity(); Map(x => x.Name); Ma...

Fluent NHibernate HasMany in Component

Below is a class model and an Oracle schema that I would like to map it to using Fluent NHibernate. public enum EnumA { Type1, Type2, Type3 }; public class ClassB { public virtual string Property1 { get; set; } public virtual string Property2 { get; set; } } public class ClassA { public virtual int ID { get; set; } publ...

How can I use a SQL Scripts in a Database Project with the System.Data.SQLite data provider?

I've got a project where I'm attempting to use SQLite via System.Data.SQLite. In my attempts to keep the database under version-control, I went ahead and created a Database Project in my VS2008. Sounds fine, right? I created my first table create script and tried to run it using right-click->Run on the script and I get this error messa...

Mapping a list of Enums

I have a table called UserPermissions with a FK to the users table by userId and then a string column for the string value of an enum. The error I am seeing is NHibernate.MappingException: An association from the table UserPermissions refers to an unmapped class: GotRoleplay.Core.Domain.Model.Permission My Permission Enum: public ...

Fluent NHibernate with development/test/production databases?

I was wondering if anyone had developed an approach for using NHibernate / Fluent NHibernate with different databases depending on the application's configuration (similar to Rails' development, test, and production databases). I believe I could get something working by using methods with conditional attributes, but I would be intereste...

How to tell Fluent NHibernate not to map a class property

I have a class that is mapped in fluent nhibernate but I want one of the classes properties to be ignored by the mapping. With class and mapping below I get this error: *The following types may not be used as proxies: iMasterengine.Data.Model.Calendar: method get_HasEvents should be virtual* //my class public class Calendar : IEntity...

Is it possible to create a database using NHibernate?

I am using NHibernate with FluentNHibernate for my DAL. I am also using SchemaExport and/or SchemaUpdate to create and update my database schema. My problem is that the schema operations all require the database to exist before they will work. I want to programmatically create my database and update the schema as there may be multiple d...

Fluent NHibernate FluentMappings.AddFromAssemblyOf<> Issue

A coworker and I were recently doing the backend for a small application using Fluent NHibernate. We wrote our entities, mapping files, persistence manager, but for some reason we couldn't export the database schema to anything. Through the debugger we discovered that the FluentMappings.AddFromAssemblyOf was returning 0 mappings, even t...

Fluent Nhibernate Nunit Test Error

I am trying to learn Nhibernate using fluent nhibernate mappings and i have created a small test app. Below is the code: UserClass: public class User { public string UserName { get; set; } public string Password { get; set; } public string Role { get; set; } public string Email { get; set; } public DateTime JoinDate...

Fluent NHibernate Automapping error

This one has me scratching my head, so I'm hoping a second pair of eyes can help me out here. Setup: I've got a base class called DomainEntity that all of my data transfer objects use. It basically only defines a property called Id (which is an integer). I've got data transfer objects: Blog, Post, User DomainEntity is in the namespace...

Fluent Nhibernate and MySql, problems with dialect

I have question about fluent nhibernate and mysql. I'm doing this: Fluently.Configure() .Database(MySQLConfiguration.Standard.ShowSql()) .Mappings(m => m.FluentMappings .AddFromAssemblyOf<ShopperMapping>()) .BuildConfiguration();SchemaExport exp = new SchemaExport(cfg); exp.Execute(true, false, false, true);...

fluent nhibernate mapping a component with reference

Is this possible... MessageMap() { Id(x => x.Id); HasMany(x => x.Folders) .Component(c => { c.Map(x => x.Name); c.References(x => x.User); }) .Cascade.All...

Fluent NHibernate Automap Joined Sub-Class Setting the Key

When automapping a joined subclass in fluent nhibernate, I can't figure out how to give the joined subclass a primary key. public class Address:Entity { public virtual string Address1 { get; set; } public virtual string Address2 { get; set; } public virtual string City { get; set; } public virtual string State { get; set; } public ...

Fluent Nhibernate Order-By on Collection

Hi, If I have a collection mapped in Fluent NHibernate and I want to apply an order to that collection how do I do that? Eg: HasMany(x => x.PastDates) .AsBag().Cascade .SaveUpdate() .KeyColumnNames.Add("EventId") .Where(e => e.DateFrom < DateTime.Now.Date) .Inverse(); I'm l...