fluent-nhibernate

Using MVC and fluent Nhibernate, how do I validate unique fields on my ViewModel before I bind them to my Domain Object and Save them?

I have a website where I allow users to create new Part records. I'm trying to figure out the best way to validate specific fields for uniqueness. I want to make sure that somebody doesn't try to add a Part with PartNumber 1234 if that PartNumber already exists on a different Part. The Web Application is using Asp.net MVC with fluen...

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...

Fluent Nhibernate causes System.IndexOutOfRangeException on Commit()

Hey there. I have been trying to figure out how to configure the mapping with both NH and FluentNH for days, and I think I'm almost there, but not quite. I have the following problem. What I need to do is basically map these two entities, which are simplified versions of the actual ones. Airlines varchar2(3) airlineCode //PK varchar2(5...

NCommon Newbie Help

I'm writing this Console app to try out NCommon. The code below doesn't get me anything back. (This is using AdventureWorks db.) class Program { static void Main(string[] args) { ISessionFactory factory = SessionProvider.CreateSessionFactory(); Store.Application.Set("NHibernateSessionFactory", factory); ...

Export Fluent Nhibernate Schema and Alter Table

I am able to generate and export the schema creation script from Fluent Nhibernate. Sometime I would like to just modify some fields or add new ones to a table after the schema creation without deleting all the tables. What I do now is that I generate the first schema script and then manually add or modify the fields to the db during the...

Fluent nHibernate: one-to-many relationship problem

I have a problem with one-to-many relationships. I have the following domain classes: public class Installation : Entity<Installation> { public virtual string Name { get; set; } public virtual IList<Institution> Institutions { get; set; } public Installation() { Institutions = new List<Institution>(); ...

FluentNHibernate Automapping not generating mappings

I'm attempting to use Fluent NHibernate auto mappings for the first time. It appears that the code I'm using isnt generating any mappings. It has been pretty much copy-pasted from the Auto mapping wiki page. var mappings = AutoMap .AssemblyOf<MvcBugs.Model.Project>(); mappings.WriteMappingsTo("c:\\temp\\mappings"); var sessionFac...

Fluent NHibernate: foreign key not null problem

I have the following domain classes: public class Installation : Entity<Installation> { public virtual string Name { get; set; } public virtual IList<Institution> Institutions { get; set; } public Installation() { Institutions = new List<Institution>(); } } public class Institution : Entity { pub...

SchemaExport with FluentNhibernate

Is there anything wrong with this code. I am not getting anything generated and no exceptions are thrown. public static void ExportSchema() { Configuration cfg = LoadDefaultConfiguration(); Fluently.Configure(cfg) .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.Load("dnnSphere.M...

(Fluent) NHibernate - Inhertiance on object level but not on table level

I have the following idea: Business object implemented as interface or abstract class with certain properties as read only to all layers except the DAL layer. I also want my business objects in another assembly than the DAL (for testing purposes), so marking the properties is not an option for me. Examples could be one to one relations...

fluent nhibernate problem mapping char(1) type

The map. public SocialCodeMap() { Id(x => x.SocialCodeId); Map(x => x.Name); Map(x => x.Code); Map(x => x.DisplayOrder); } And the Class. public class SocialCode { public virtual Guid SocialCodeId { get; set; } public virtual string Name { get; set; } public virtual char Code { ...

Error while creating Fluent NHibernate Session factory.

Hi, I wonder if any one has had any experience of the following fluent config error. faultString = "An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. I have no problems on my development box but when the dlls are put up on the prod...

NHibernate: set id to interface mapping

I try to write a (fluent) mapping against an interface public interface IOrderDiscount : IDomainObject<long> where public interface IDomainObject<IdT> : IDomainObject { IdT Id { get; } } like so (and all other thinkable varieties of access strategies) Id(d => d.Id, "DiscountId") .GeneratedBy.HiLo("9") .WithUnsavedValue...

NHibernate or FluentNHibernate or ActiveRecord?

I am in a stage of mapping my CSharp classes into database tables. I have decided to use NHibernate as my ORM tool after comparing with other tools. I have never done a real project with NHibernate before and now am considering alternatives for the mapping, ActiveRecord: according to the project's web site, using ActiveRecord can boost...

assembly does not allow partially trusted callers

Hi, I am building a site using fluent NHibernate, which works just fine on the dev box. However, after I uploaded it to my host I get the following when trying to run it. "System.TypeInitializationException: The type initializer for 'NHibernate.ByteCode.Castle.ProxyFactory' threw an exception. ---> System.Security.SecurityException: ...

NHibernate: simple delete orphan scenario not working

I'm trying to have a simple one to many relationship/hierarchy using NHibernate. I would like orphans to be deleted automatically but my current attempts to do so all result in an ObjectDeletedException. I'm wondering if someone can tell me what I'm doing incorrectly. EDIT: I should have specified that I'm loading a root Foo, then remo...

NHibernate unique constraints

I've run into some trouble with unique constraints in NHibernate. I have a User entity that is mapped with a unique constraint for the Username property. What I want to do is to be able to check if a particular username exists before a new user is added and also before an existing user updates it's username. The first scenario (adding ...

wont save to database with guid as id- fluent-nhiberate

hi. i got problems with saving when i use Guid as identifier. can anybody se what i am missing here? i create my own guid so i dont want it to be generated by database. NOTE: i have tried the guid.combo in mapping to without any success. public class Order { public virtual Guid Id { get; set; } public virtual ICollection<Orde...

Mapping enum with fluent nhibernate

I am following the http://wiki.fluentnhibernate.org/Getting%5Fstarted tutorial to create my first NHibernate project with Fluent NHibernate I have 2 tables 1) Account with fields Id AccountHolderName AccountTypeId 2) AccountType with fields Id AccountTypeName Right now the account types can be Savings or Current So the table Acco...

Relation problems with Fluent NHibernate and Automappings

I have made a simple example application to test Fluent NHibernate with the automapping feature but I get an exception when I save. This is how my example looks like: public class Item { public virtual int Id { get; protected set; } public virtual string Name { get; set; } public virtual IList<Detail> Details { get; set; }...