Search Results

Search found 97 results on 4 pages for 'fluentnhibernate'.

Page 2/4 | < Previous Page | 1 2 3 4  | Next Page >

  • Using FluentNHibernate + SQLite with .Net4?

    - by stiank81
    I have a WPF application running with .Net3.5 using FluentNHibernate, and all works fine. When I upgraded to VS2010 I ran into some odd problems, but after changing to use x64 variant of SQLite it worked fine again. Now I want to change to use .Net4, but this has turned into a more painful experience then I expected.. When calling FluentConfiguration.BuildConfiguration I get an exception thrown: FluentConfigurationException unhandled An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail The inner exception gives us more information: Message = "Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4." It has an InnerException again: Exception has been thrown by the target of an invocation. Which again has an InnerException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly. Now - to me it sounds like it doesn't find System.Data.SQLite.dll, but I can't understand this. Everywhere this is referenced I have "Copy Local", and I have verified that it is in every build folder for projects using SQLite. I have also copied it manually to every Debug folder of the solution - without luck. Notes: This exact same code worked just fine before I upgraded to .Net4. I did see some x64 x86 mismatch problems earlier, but I have switched to use x86 as the target platform and for all referenced dlls. I have verified that all files in the Debug-folder are x86. I have tried the precompiled Fluent dlls, I have tried compiling myself, and I have compiled my own version of Fluent using .Net4. I see that there are also others that have seen this problem, but I haven't really seen any solution yet. After @devio's answer I tried adding a reference to the SQLite dll. This didn't change anything, but I hope I made it right though.. This is what I added to the root node of the app.config file: <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <qualifyAssembly partialName="System.Data.SQLite" fullName="System.Data.SQLite, Version=1.0.60.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" /> </assemblyBinding> </runtime> Anyone out there using Fluent with .Net4 and SQLite successfully? Help! I'm lost...

    Read the article

  • Problems using FluentNHibernate + SQLite with .NET4?

    - by stiank81
    I have a WPF application running with VS2010 .Net3.5 using Nhibernate with FluentNHibernate + SQLite, and all works fine. Now I want to change to use .Net4, but this has turned into a more painful experience then I expected.. When setting up the connection a FluentConfigurationException is thrown from FluentConfiguration.BuildConfiguration saying: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more details. The inner exception gives us more information: Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. It has an InnerException again: Exception has been thrown by the target of an invocation. Which again has an InnerException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly. Now - to me it sounds like it doesn't find System.Data.SQLite.dll, but I can't understand this. Everywhere this is referenced I have "Copy Local", and I have verified that it is in every build folder for projects using SQLite. I have also copied it manually to every Debug folder of the solution - without luck. Notes: This is exactly the same code that worked just fine before I upgraded to .Net4. I did see some x64 x86 mismatch problems earlier, but I have switched to use x86 as the target platform and for all referenced dlls. I have verified that all files in the Debug-folder are x86. I have tried the precompiled Fluent dlls, I have tried compiling myself, and I have compiled my own version of Fluent using .Net4. I see that there are also others that have seen this problem, but I haven't really seen any solution yet. After @devio's answer I tried adding a reference to the SQLite dll. This didn't change anything, but I hope I made it right though.. This is what I added to the root node of the app.config file: <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <qualifyAssembly partialName="System.Data.SQLite" fullName="System.Data.SQLite, Version=1.0.60.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" /> </assemblyBinding> </runtime> Anyone out there using Fluent with .Net4 and SQLite successfully? Help! I'm lost...

    Read the article

  • Cant insert row with auto-increment key via FluentNhibernate

    - by Jeff Shattock
    I'm getting started with Fluent NHibernate, and NHibernate in general. I'm trying to do something that I feel is pretty basic, but I cant quite get it to work. I'm trying to add a new entry to a simple table. Here's the Entity class. public class Product { public Product() { id = 0; } public virtual int id {get; set;} public virtual string description { get; set; } } Here's its mapping. public class ProductMap : ClassMap<Product> { public ProductMap() { Id(p => p.id).GeneratedBy.Identity().UnsavedValue(0); Map(p => p.description); } } I've tried that with and without the additional calls after Id(). And the insert code: var p = new Product() { description = "Apples" }; using (var s = _sf.CreateSession()) { s.Save(new_product); s.Flush(); } where _sf is a properly configured SessionSource. When I execute this code, I get: NHibernate.AssertionFailure : null identifier, which makes sense based on the SQL that NHibernate is executing: INSERT INTO "Product" (description) VALUES (@p0);@p0 = 'Apples' It doesnt seem to be trying to set the Id field, which seems ok (on its face) since the DB should generate that. But its not, I think. The DB schema is autogenerated by FNH: var config = Fluently.Configure().Database(MsSqlCeConfiguration.Standard.ShowSql().ConnectionString(@"Data Source=Database1.sdf")); var SessionSource = new SessionSource(config.BuildConfiguration().Properties, new ModelMappings()); var Session = SessionSource.CreateSession(); SessionSource.BuildSchema(Session); CreateInitialData(Session); Session.Flush(); Session.Clear(); I'm sure to be doing tons of things wrong, but whats the one thats causing this error?

    Read the article

  • FluentNhibernate IDictionary<Entity,ValueObject>

    - by Miguel Marques
    I had a mapping for a IDictionary<StocksLocation,decimal> property, this was the mapping: HasMany<StocksLocation>(mq => mq.StocksLocation) .KeyColumn("IDProduct") .AsEntityMap("IDLocation") .Element("Quantity", qt => qt.Type<decimal>()); Now i changed from decimal to a Value Object: Quantity. Quantity has two properties, decimal Value and Unit Unit (where Unit is an enum). I now have to map IDictionary<StocksLocation,Quantity>, how can i achieve this? Thanks in advance

    Read the article

  • FluentNHibernate SQLite configuration exception - after switching to .net4

    - by stiank81
    I get an exception thrown when trying to use Fluent to configure my NHibernate connection to SQLite. The code I use to configure is as follows: var cfg = Fluently.Configure(). Database(SQLiteConfiguration.Standard.ShowSql().UsingFile("MyDb.db")). Mappings(m => m.FluentMappings.AddFromAssemblyOf<MappingsPersistenceModel>()); _sessionFactory = cfg.BuildSessionFactory(); A HibernateException is thrown when BuildSessionFactory() is called, saying: Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. It has an InnerException: Exception has been thrown by the target of an invocation. Which again has an InnerException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly. Now - to me it sounds like it doesn't find System.Data.SQLite.dll, but I can't understand this. Everywhere this is referenced I have "Copy Local", and I have verified that it is in every build folder for projects using SQLite. I have also copied it manually to every Debug folder of the solution - without luck. What can be causing this? Any ideas? My suspicion is that it is related to .Net4 somehow. The reason is that it worked just fine when I used .Net3.5, and then I changed to .Net4, and the problem started. You can also check out this other question for a more general approach towards Fluent-.Net4 compatibility.

    Read the article

  • FluentNhibernate many-to-many mapping - resolving record is not inserted

    - by Dmitriy Nagirnyak
    Hi, I have a many-to-many mapping defined (only relevant fields included): // MODEL: public class User : IPersistentObject { public User() { Permissions = new HashedSet<Permission>(); } public virtual int Id { get; protected set; } public virtual ISet<Permission> Permissions { get; set; } } public class Permission : IPersistentObject { public Permission() { } public virtual int Id { get; set; } } // MAPPING: public class UserMap : ClassMap<User> { public UserMap() { Id(x => x.Id); HasManyToMany(x => x.Permissions).Cascade.All().AsSet(); } } public class PermissionMap : ClassMap<Permission> { public PermissionMap() { Id(x => x.Id).GeneratedBy.Assigned(); Map(x => x.Description); } } The following test fails as there is no record inserted into User_Permission table: [Test] public void AddingANewUserPrivilegeShouldSaveIt() { var p1 = new Permission { Id = 123, Description = "p1" }; Session.Save(p1); var u = new User { Email = "[email protected]" }; u.Permissions.Add(p1); Session.Save(u); var userId = u.Id; Session.Evict(u); Session.Get<User>(userId).Permissions.Should().Not.Be.Empty(); } The SQL executed is (SQLite): INSERT INTO "Permission" (Description, Id) VALUES (@p0, @p1);@p0 = 'p1', @p1 = 1 INSERT INTO "User" (Email) VALUES (@p0); select last_insert_rowid();@p0 = '[email protected]' SELECT user0_.Id as Id2_0_, user0_.Email as Email2_0_ FROM "User" user0_ WHERE user0_.Id=@p0;@p0 = 1 SELECT permission0_.UserId as UserId1_, permission0_.PermissionId as Permissi2_1_, permission1_.Id as Id4_0_, permission1_.Description as Descript2_4_0_ FROM User_Permissions permission0_ left outer join "Permission" permission1_ on permission0_.PermissionId=permission1_.Id WHERE permission0_.UserId=@p0;@p0 = 1 We can clearly see that there is no record inserted into the User_Permissions table where it should be. Not sure what I am doing wrong and need an advice. So can you please help me to pass this test. Thanks, Dmitriy.

    Read the article

  • Help creating a ColumnName Convention using FluentNHibernate

    - by Rafael E. Belliard
    I've been trying to specify a custom naming convention for my database table columns. So far, I have been able to setup a convention for the table's name, but not the actual columns. I've seen a few guides on the internet, but they're not working using the latest Fluent NHibernate (1.0.0 RTM). public class CamelCaseSplitNamingConvention : IClassConvention, IComponentConvention { public void Apply(IClassInstance instance) { instance.Table(instance.EntityType.Name.ChangeCamelCaseToUnderscore()); } public void Apply(IComponentInstance instance) { // is this the correct call for columns? If not, which one? } } Please help.

    Read the article

  • FluentNHibernate mapping of composite foreign keys

    - by Faron
    I have an existing database schema and wish to replace the custom data access code with Fluent.NHibernate. The database schema cannot be changed since it already exists in a shipping product. And it is preferable if the domain objects did not change or only changed minimally. I am having trouble mapping one unusual schema construct illustrated with the following table structure: CREATE TABLE [Container] ( [ContainerId] [uniqueidentifier] NOT NULL, CONSTRAINT [PK_Container] PRIMARY KEY ( [ContainerId] ASC ) ) CREATE TABLE [Item] ( [ItemId] [uniqueidentifier] NOT NULL, [ContainerId] [uniqueidentifier] NOT NULL, CONSTRAINT [PK_Item] PRIMARY KEY ( [ContainerId] ASC, [ItemId] ASC ) ) CREATE TABLE [Property] ( [ContainerId] [uniqueidentifier] NOT NULL, [PropertyId] [uniqueidentifier] NOT NULL, CONSTRAINT [PK_Property] PRIMARY KEY ( [ContainerId] ASC, [PropertyId] ASC ) ) CREATE TABLE [Item_Property] ( [ContainerId] [uniqueidentifier] NOT NULL, [ItemId] [uniqueidentifier] NOT NULL, [PropertyId] [uniqueidentifier] NOT NULL, CONSTRAINT [PK_Item_Property] PRIMARY KEY ( [ContainerId] ASC, [ItemId] ASC, [PropertyId] ASC ) ) CREATE TABLE [Container_Property] ( [ContainerId] [uniqueidentifier] NOT NULL, [PropertyId] [uniqueidentifier] NOT NULL, CONSTRAINT [PK_Container_Property] PRIMARY KEY ( [ContainerId] ASC, [PropertyId] ASC ) ) The existing domain model has the following class structure: The Property class contains other members representing the property's name and value. The ContainerProperty and ItemProperty classes have no additional members. They exist only to identify the owner of the Property. The Container and Item classes have methods that return collections of ContainerProperty and ItemProperty respectively. Additionally, the Container class has a method that returns a collection of all of the Property objects in the object graph. My best guess is that this was either a convenience method or a legacy method that was never removed. The business logic mainly works with Item (as the aggregate root) and only works with a Container when adding or removing Items. I have tried several techniques for mapping this but none work so I won't include them here unless someone asks for them. How would you map this?

    Read the article

  • AutoMapping Custom Collections with FluentNHibernate

    - by ScottBelchak
    I am retrofitting a very large application to use NHibernate as it's data access strategy. Everything is going well with AutoMapping. Luckily when the domain layer was built, we used a code generator. The main issue that I am running into now is that every collection is hidden behind a custom class that derives from List<. For example public class League { public OwnerList owners {get;set;} } public class OwnerList : AppList<Owner> { } public class AppList<T> : List<T> { } What kind of Convention do I have to write to get this done?

    Read the article

  • Moving from NHibernate to FluentNHibernate: assembly error (related to versions)?

    - by goober
    Not sure where to start, but I had gotten the most recent version of NHibernate, successfully mapped the most simple of business objects, etc. When trying to move to FluentNHibernate and do the same thing, I got this error message on build: "System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference." Background: I'm new to Hibernate, NHibernate, and FluentNHibernate -- but not to .NET, C#, etc. Database I have a database table called Category: (PK) CategoryID (type: int), unique, auto-incrementing UserID (type: uniqueidentifier) -- given the value of the user Guid in ASP.NET database Title (type: varchar(50) -- the title of the category Components involved: I have a SessionProviderClass which creates the mapping to the database I have a Category class which has all the virtual methods for FluentNHibernate to override I have a CategoryMap : ClassMap class, which does the fluent mappings for the entity I have a CategoryRepository class that contains the method to add & save the category I have the TestCatAdd.aspx file which uses the CategoryRepository class. Would be happy to post code for any of those, but I'm not sure that it's necessary, as I think the issue is that somewhere there's a version conflict between what FluentNHibernate references and the NHibernate I have installed from before. Thanks in advance for any help you can give!

    Read the article

  • What would be the equivalent VB.NET code for this C# FluentNHibernate component mapping?

    - by Will Marcouiller
    I'm a C# programmer constrained to write VB.NET code. While exploring NHibernate further for my current client, I encountered FluentNHibernate, which I find real attractive. But now, I wonder how to "translate" this C# code for component mapping into VB.NET code: Component(x => x.Address, m => { m.Map(x => x.Number); m.Map(x => x.Street); m.Map(x => x.PostCode); }); I know from here: Component(Of Client)(Function(c) c.Address, ...) what I miss is how to continue with the brackets in VB.NET, since there's no Begin End keywords or so. EDIT 1: Following Mr. JaredPar instructions, I figured that his solution might work. If we take the time to read his answer, we may notice that we both don't know what the MType is within his solution. I might have found out that the MType is: FluentNHibernate.Mapping.ComponentPart(Of TComponent) Thus, TComponent is, from my understanding, an anonymous type that I shall parameter to use. From this point of view, since I wish to map the properties of my Address object, replacing TComponent in my help method signature seems not to work. Private Sub MapAdresseHelper(Of Adresse)(ByVal a As FluentNHibernate.Mapping.ComponentPart(Of Adresse)) a.Map(Function(m) m.Number) a.Map(Function(m) m.Street).Length(50) a.Map(Function(m) m.PostCode).Length(10) End Sub The error I get is that my Address class doesn't have a property member named Street, for instance. It sees my Address type, it recognizes it, but it seems buggy somehow. I guess VBNET is poorly designed for lambda expressions and is less evolved than C# (Sorry, a bit of frustration due to the constraint of working with it and not being capable of doing things VERY easily done in C#.) Thanks!

    Read the article

  • How do I use Fluent NHibernate with .NET 4.0?

    - by Tomas Lycken
    I want to learn to use Fluent NHibernate, and I'm working in VS2010 Beta2, compiling against .NET 4, but I'm experiencing some problems. Summary My main problem (at the moment) is that the namespace FluentNHibernate isn't available even though I've imported all the .dll assemblies mentioned in this guide. This is what I've done: 1. I downloaded the Fluent NHibernate source from here, extracted the .zip and opened the solution in VS. A dialog asked me if I wanted to convert the solution to a VS2010 solution, so I did. 2. I then went into each project's properties and configured all of them to compile for .NET 4, and built the entire solution. 3. I copied all the .dll files from /bin/Debug/ in the FluentNHibernate to a new folder on my local hard drive. 4. In my example project, I referenced FluentNHibernate.dll and NHibernate.dll from the new folder. This is my problem: If I right-click on FluentNHibernate in the References list and select "View in Object Browser...", it shows up correctly. Now, when I try to create a mapping class, I can't import FluentNHibernate. This code: using FluentNHibernate.Mapping; namespace FluentNHExample.Mappings { } generates an error on the using statement, saying The type or namespace 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?). The FluentNHibernate assembly is still in the list of References of my project, but if I try to browse the assembly in Object Browser again, it can't be found. What is causing this?

    Read the article

  • FluentNHibernate: multiple one-to-many relationships between the same entities.

    - by Venemo
    Hi, I'm working on a bug tracking application. There are tickets, and each ticket has an opener user and an assigned user. So, basically, I have two entities, which have two many-to-one relationships with each other. Their schematic is this: User: public class User { public virtual int Id { get; private set; } ... public virtual IList<Ticket> OpenedTickets { get; set; } public virtual IList<Ticket> AssignedTickets { get; set; } } Ticket: public class Ticket { public virtual int Id { get; protected set; } ... [Required] public virtual User OpenerUser { get; set; } public virtual User AssignedUser { get; set; } } I use FluentNHibernate's auto mapping feature. The problem is, that no matter whether relationship I set, on the side of the User, both collections always contain the same data. I guess Fluent can't tell which end of which relationship belongs to where. I googled around but haven't found anything useful. Could anyone help me, please?

    Read the article

  • FluentNHibernate Many-To-One References where Foreign Key is not to Primary Key and column names are

    - by Todd Langdon
    I've been sitting here for an hour trying to figure this out... I've got 2 tables (abbreviated): CREATE TABLE TRUST ( TRUSTID NUMBER NOT NULL, ACCTNBR VARCHAR(25) NOT NULL ) CONSTRAINT TRUST_PK PRIMARY KEY (TRUSTID) CREATE TABLE ACCOUNTHISTORY ( ID NUMBER NOT NULL, ACCOUNTNUMBER VARCHAR(25) NOT NULL, TRANSAMT NUMBER(38,2) NOT NULL POSTINGDATE DATE NOT NULL ) CONSTRAINT ACCOUNTHISTORY_PK PRIMARY KEY (ID) I have 2 classes that essentially mirror these: public class Trust { public virtual int Id {get; set;} public virtual string AccountNumber { get; set; } } public class AccountHistory { public virtual int Id { get; set; } public virtual Trust Trust {get; set;} public virtual DateTime PostingDate { get; set; } public virtual decimal IncomeAmount { get; set; } } How do I do the many-to-one mapping in FluentNHibernate to get the AccountHistory to have a Trust? Specifically, since it is related on a different column than the Trust primary key of TRUSTID and the column it is referencing is also named differently (ACCTNBR vs. ACCOUNTNUMBER)???? Here's what I have so far - how do I do the References on the AccountHistoryMap to Trust??? public class TrustMap : ClassMap<Trust> { public TrustMap() { Table("TRUST"); Id(x => x.Id).Column("TRUSTID"); Map(x => x.AccountNumber).Column("ACCTNBR"); } } public class AccountHistoryMap : ClassMap<AccountHistory> { public AccountHistoryMap() { Table("TRUSTACCTGHISTORY"); Id (x=>x.Id).Column("ID"); References<Trust>(x => x.Trust).Column("ACCOUNTNUMBER").ForeignKey("ACCTNBR").Fetch.Join(); Map(x => x.PostingDate).Column("POSTINGDATE"); ); I've tried a few different variations of the above line but can't get anything to work - it pulls back AccountHistory data and a proxy for the Trust; however it says no Trust row with given identifier. This has to be something simple. Anyone? Thanks in advance.

    Read the article

  • How to create mapping for a List<SomeNativeType> in FluentNhibernate ?

    - by Mahesh Velaga
    Hi all, I am trying to create a mapping file for the following Model using Fluent NHibernate. But, I am not sure of how to do the mapping for the List in the mapping file. public class MyClass { public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual List<string> MagicStrings { get; set; } } public class EnvironmentMapping : ClassMap<Models.Environment> { public EnvironmentMapping() { Id(x => x.Id); Map(x => x.Name); //HasMany(x => string) What should this be ? } } Help in this regard is much appreciated. Thanks!

    Read the article

  • How to map this class in NHibernate (not FluentNHibernate)?

    - by JMSA
    Suppose I have a database like this: This is set up to give role-wise menu permissions. Please note that, User-table has no direct relationship with Permission-table. Then how should I map this class against the database-tables? class User { public int ID { get; set; } public string Name { get; set; } public string Username { get; set; } public string Password { get; set; } public bool? IsActive { get; set; } public IList<Role> RoleItems { get; set; } public IList<Permission> PermissionItems { get; set; } public IList<string> MenuItemKeys { get; set; } } This means, (1) Every user has some Roles. (2) Every user has some Permissions (depending on to Roles). (3) Every user has some permitted MenuItemKeys (according to Permissions). How should my User.hbm.xml look like?

    Read the article

  • "The name 'WithTable' does not exist in the current context" using Fluent NHibernate

    - by Byron Sommardahl
    Might be a really easy problem to fix, but it the solution is eluding me! I'm using Fluent NHibernate 1.0 RTM (and using NHibernate bins that ships with it). I'm trying to map my entities and cannot use the WithTable() method. It's not available in Intelligence and VS doesn't suggest any namespaces to reference. Here's my code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using GeoCodeThe.Net.Domain.Entities; using FluentNHibernate.Mapping; namespace GeoCodeThe.Net.Domain.Mappings { class CategoryMap: ClassMap<ICategory> { public CategoryMap() { WithTable("Categories"); // <----- Compile error: The name 'WithTable' does not exist in the current context Id(x => x.Id); Map(x => x.Name); Map(x => x.Tags); } } My bin folder has: Antlr3.Runtime.dll Castle.Core.dll Castle.DynamicProxy2.dll FluentNHibernate.dll Iesi.Collections.dll log4net.dll NHibernate.ByteCode.Castle.dll NHibernate.dll FluentNHibernate.pdb Castle.Core.xml Castle.DynamicProxy2.xml FluentNHibernate.xml Iesi.Collections.xml log4net.xml NHibernate.ByteCode.Castle.xml NHibernate.xml Any clue what I'm missing? Let me know if you need any more clarification.

    Read the article

  • Cascade Saves with Fluent NHibernate AutoMapping - Old Anwser Still Valid?

    - by Glenn
    I want to do exactly what this question asks: http://stackoverflow.com/questions/586888/cascade-saves-with-fluent-nhibernate-automapping Using Fluent Nhibernate Mappings to turn on "cascade" globally once for all classes and relation types using one call rather than setting it for each mapping individually. The answer to the earlier question looks great, but I'm afraid that the Fluent Nhibernate API altered its .WithConvention syntax last year and broke the answer... either that or I'm missing something. I keep getting a bunch of name space not found errors relating to the IOneToOnePart, IManyToOnePart and all their variations: "The type or namespace name 'IOneToOnePart' could not be found (are you missing a using directive or an assembly reference?)" I've tried the official example dll's, the RTM dll's and the latest build and none of them seem to make VS 2008 see the required namespace. The second problem is that I want to use the class with my AutoPersistenceModel but I'm not sure where to this line: .ConventionDiscovery.AddFromAssemblyOf() in my factory creation method. private static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database(SQLiteConfiguration.Standard.UsingFile(DbFile)) .Mappings(m => m.AutoMappings .Add(AutoMap.AssemblyOf<Shelf>(type => type.Namespace.EndsWith("Entities")) .Override<Shelf>(map => { map.HasManyToMany(x => x.Products).Cascade.All(); }) ) )//emd mappings .ExposeConfiguration(BuildSchema) .BuildSessionFactory();//finalizes the whole thing to send back. } Below is the class and using statements I'm trying using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using FluentNHibernate.Conventions; using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using NHibernate; using NHibernate.Cfg; using NHibernate.Tool.hbm2ddl; using FluentNHibernate.Mapping; namespace TestCode { public class CascadeAll : IHasOneConvention, IHasManyConvention, IReferenceConvention { public bool Accept(IOneToOnePart target) { return true; } public void Apply(IOneToOnePart target) { target.Cascade.All(); } public bool Accept(IOneToManyPart target) { return true; } public void Apply(IOneToManyPart target) { target.Cascade.All(); } public bool Accept(IManyToOnePart target) { return true; } public void Apply(IManyToOnePart target) { target.Cascade.All(); } } }

    Read the article

  • No persister for: <ClassName> issue with Fluent NHibernate

    - by Amit
    I have following code: //AutoMapConfig.cs using System; using FluentNHibernate.Automapping; namespace SimpleFNH.AutoMap { public class AutoMapConfig : DefaultAutomappingConfiguration { public override bool ShouldMap(Type type) { return type.Namespace == "Examples.FirstAutomappedProject.Entities"; } } } //CascadeConvention.cs using FluentNHibernate.Conventions; using FluentNHibernate.Conventions.Instances; namespace SimpleFNH.AutoMap { public class CascadeConvention : IReferenceConvention, IHasManyConvention, IHasManyToManyConvention { public void Apply(IManyToOneInstance instance) { instance.Cascade.All(); } public void Apply(IOneToManyCollectionInstance instance) { instance.Cascade.All(); } public void Apply(IManyToManyCollectionInstance instance) { instance.Cascade.All(); } } } //Item.cs namespace SimpleFNH.Entities { public class Item { public virtual long ID { get; set; } public virtual string ItemName { get; set; } public virtual string Description { get; set; } public virtual OrderItem OrderItem { get; set; } } } //OrderItem.cs namespace SimpleFNH.Entities { public class OrderItem { public virtual long ID { get; set; } public virtual int Quantity { get; set; } public virtual Item Item { get; set; } public virtual ProductOrder ProductOrder { get; set; } public virtual void AddItem(Item item) { item.OrderItem = this; } } } using System; using System.Collections.Generic; //ProductOrder.cs namespace SimpleFNH.Entities { public class ProductOrder { public virtual long ID { get; set; } public virtual DateTime OrderDate { get; set; } public virtual string CustomerName { get; set; } public virtual IList<OrderItem> OrderItems { get; set; } public ProductOrder() { OrderItems = new List<OrderItem>(); } public virtual void AddOrderItems(params OrderItem[] items) { foreach (var item in items) { OrderItems.Add(item); item.ProductOrder = this; } } } } //NHibernateRepo.cs using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using NHibernate; using NHibernate.Criterion; using NHibernate.Tool.hbm2ddl; namespace SimpleFNH.Repository { public class NHibernateRepo { private static ISessionFactory _sessionFactory; private static ISessionFactory SessionFactory { get { if (_sessionFactory == null) InitializeSessionFactory(); return _sessionFactory; } } private static void InitializeSessionFactory() { _sessionFactory = Fluently.Configure().Database( MsSqlConfiguration.MsSql2008.ConnectionString( @"server=Amit-PC\SQLEXPRESS;database=SimpleFNH;Trusted_Connection=True;").ShowSql()). Mappings(m => m.FluentMappings.AddFromAssemblyOf<Order>()).ExposeConfiguration( cfg => new SchemaExport(cfg).Create(true, true)).BuildSessionFactory(); } public static ISession OpenSession() { return SessionFactory.OpenSession(); } } } //Program.cs using System; using System.Collections.Generic; using System.Linq; using SimpleFNH.Entities; using SimpleFNH.Repository; namespace SimpleFNH { class Program { static void Main(string[] args) { using (var session = NHibernateRepo.OpenSession()) { using (var transaction = session.BeginTransaction()) { var item1 = new Item { ItemName = "item 1", Description = "test 1" }; var item2 = new Item { ItemName = "item 2", Description = "test 2" }; var item3 = new Item { ItemName = "item 3", Description = "test 3" }; var orderItem1 = new OrderItem { Item = item1, Quantity = 2 }; var orderItem2 = new OrderItem { Item = item2, Quantity = 4 }; var orderItem3 = new OrderItem { Item = item3, Quantity = 5 }; var productOrder = new ProductOrder { CustomerName = "Amit", OrderDate = DateTime.Now, OrderItems = new List<OrderItem> { orderItem1, orderItem2, orderItem3 } }; productOrder.AddOrderItems(orderItem1, orderItem2, orderItem3); session.Save(productOrder); transaction.Commit(); } } using (var session = NHibernateRepo.OpenSession()) { // retreive all stores and display them using (session.BeginTransaction()) { var orders = session.CreateCriteria(typeof(ProductOrder)) .List<ProductOrder>(); foreach (var item in orders) { Console.WriteLine(item.OrderItems.First().Quantity); } } } } } } I tried many variations to get it working but i get an error saying No persister for: SimpleFNH.Entities.ProductOrder Can someone help me get it working? I wanted to create a simple program which will set a pattern for my bigger project but it is taking quite a lot of time than expected. It would be rally helpful if you can explain in simple terms on any template/pattern that i can use to get fluent nHibernate working. The above code uses auto mapping, which i tried after i tried with fluent mapping.

    Read the article

  • change custom mapping - sharp architecture/ fluent nhibernate

    - by csetzkorn
    I am using the sharp architecture which also deploys FNH. The db schema sql code is generated during the testing like this: [TestFixture] [Category("DB Tests")] public class MappingIntegrationTests { [SetUp] public virtual void SetUp() { string[] mappingAssemblies = RepositoryTestsHelper.GetMappingAssemblies(); configuration = NHibernateSession.Init( new SimpleSessionStorage(), mappingAssemblies, new AutoPersistenceModelGenerator().Generate(), "../../../../app/XXX.Web/NHibernate.config"); } [TearDown] public virtual void TearDown() { NHibernateSession.CloseAllSessions(); NHibernateSession.Reset(); } [Test] public void CanConfirmDatabaseMatchesMappings() { var allClassMetadata = NHibernateSession.GetDefaultSessionFactory().GetAllClassMetadata(); foreach (var entry in allClassMetadata) { NHibernateSession.Current.CreateCriteria(entry.Value.GetMappedClass(EntityMode.Poco)) .SetMaxResults(0).List(); } } /// <summary> /// Generates and outputs the database schema SQL to the console /// </summary> [Test] public void CanGenerateDatabaseSchema() { System.IO.TextWriter writeFile = new StreamWriter(@"d:/XXXSqlCreate.sql"); var session = NHibernateSession.GetDefaultSessionFactory().OpenSession(); new SchemaExport(configuration).Execute(true, false, false, session.Connection, writeFile); } private Configuration configuration; } I am trying to use: using FluentNHibernate.Automapping; using xxx.Core; using SharpArch.Data.NHibernate.FluentNHibernate; using FluentNHibernate.Automapping.Alterations; namespace xxx.Data.NHibernateMaps { public class x : IAutoMappingOverride<x> { public void Override(AutoMapping<Tx> mapping) { mapping.Map(x => x.text, "text").CustomSqlType("varchar(max)"); mapping.Map(x => x.url, "url").CustomSqlType("varchar(max)"); } } } To change the standard mapping of strings from NVARCHAR(255) to varchar(max). This is not picked up during the sql schema generation. I also tried: mapping.Map(x = x.text, "text").Length(100000); Any ideas? Thanks. Christian

    Read the article

  • AssertionFailure: "null identifier" - FluentNH + SQLServerCE

    - by Stefan
    The code fails at session.Save(employee); with AssertionFailure "null identifier". What am I doing wrong? using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using FluentNHibernate.Mapping; using NHibernate; using NHibernate.Cfg; using NHibernate.Tool.hbm2ddl; namespace FNHTest { public class Employee { public virtual int Id { get; private set; } public virtual string Name { get; set; } public virtual string Surname { get; set; } } public class EmployeeMap : ClassMap { public EmployeeMap() { Id(e = e.Id); Map(e = e.Name); Map(e = e.Surname); } } public class DB { private static ISessionFactory mySessionFactory = null; private static ISessionFactory SessionFactory { get { if (mySessionFactory == null) { mySessionFactory = Fluently.Configure() .Database(MsSqlCeConfiguration.Standard .ConnectionString("Data Source=MyDB.sdf")) .Mappings(m = m.FluentMappings.AddFromAssemblyOf()) .ExposeConfiguration(BuildSchema) .BuildSessionFactory(); } return mySessionFactory; } } private static void BuildSchema(Configuration configuration) { SchemaExport schemaExport = new SchemaExport(configuration); schemaExport.Execute(false, true, false); } public static ISession OpenSession() { return SessionFactory.OpenSession(); } } public class Program { public static void Main(string[] args) { var employee = new Employee { Name = "John", Surname = "Smith" }; using (ISession session = DB.OpenSession()) { session.Save(employee); } } } }

    Read the article

  • Fluent NHibernate and PostgreSQL, SchemaMetadataUpdater.QuoteTableAndColumns - System.NotSupportedEx

    - by Vyacheslav
    Hello! I'm using fluentnhibernate with PostgreSQL. Fluentnhibernate is last version. PosrgreSQL version is 8.4. My code for create ISessionFactory: public static ISessionFactory CreateSessionFactory() { string connectionString = ConfigurationManager.ConnectionStrings["PostgreConnectionString"].ConnectionString; IPersistenceConfigurer config = PostgreSQLConfiguration.PostgreSQL82.ConnectionString(connectionString); FluentConfiguration configuration = Fluently .Configure() .Database(config) .Mappings(m => m.FluentMappings.Add(typeof(ResourceMap)) .Add(typeof(TaskMap)) .Add(typeof(PluginMap))); var nhibConfig = configuration.BuildConfiguration(); SchemaMetadataUpdater.QuoteTableAndColumns(nhibConfig); return configuration.BuildSessionFactory(); } When I'm execute code at line SchemaMetadataUpdater.QuoteTableAndColumns(nhibConfig); throw error: System.NotSupportedException: Specified method is not supported. Help me, please! I'm very need for solution. Best regards

    Read the article

  • Fluent NHibernate MappingException : could not instantiate id generator

    - by Mark Simpson
    I'm pottering around with Fluent NHibernate to try and get a simple app up and running. I'm running through this Fluent NHibernate Tutorial. Everything seems to be going fine and I've created the required classes etc. and it all builds, but when I run the test, I get an exception. Someone in the comments section of the tutorial has the same problem, but I can't find any good information on what's causing it. Any help appreciated. It's probably something trivial. Exception details: FluentNHTest.Tests.Mappings.CustomerMappingTests.ValidateMappings: FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. ---- FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. ---- NHibernate.MappingException : could not instantiate id generator ---- System.FormatException : Input string was not in a correct format.

    Read the article

< Previous Page | 1 2 3 4  | Next Page >