fluent-nhibernate

NHibernate: Saving different types of objects in the same session breaks batching

徘徊边缘 提交于 2019-12-11 07:51:12
问题 newbie here, sorry if this is an obvious question. It seems saving different types of objects in the same session breaks batching, cause significant performance drop. ID generator is set to Increment (as Diego Mijelshon advised, I tried hilo("100"), but unfortunately same issue, Test1() is still about 5 times slower than Test2()): public class CustomIdConvention : IIdConvention { public void Apply(IIdentityInstance instance) { instance.GeneratedBy.Increment(); } } AdoNetBatchSize is set to

NHibernte Fluent vs XML mapping

筅森魡賤 提交于 2019-12-11 07:33:52
问题 I see a lot of buzz generated around NH Fluent interface, so what is the benefit of using Fluent instead of XML mapping and Criteria API? 回答1: Refactoring friendly (renames won't break mappings) Automappings with configurable conventions Intellisense in mappings for your domain Compile time validation 回答2: What I found most useful is AutoMapping by conventions feature in Fluent NH. Basically it maps everything for you, and if you need some complex mapping then you can override it by property.

NHibernate write value = NULL when ID < 0

烈酒焚心 提交于 2019-12-11 07:07:42
问题 We would like to implement a simple rule in which NHibernate would assign (persist) NULL to the database when the ID for the entity is equal to -1. For example, we have an "in system" account which should be persisted to the database as NULL. If we try to persist the ID of -1 to the database we get a Foreign key exception because the ID does not exist in the foreign table. We are using NHibernate with FluentNhibernate. 回答1: I think you didn't a proper mapping of your entity. If it were

Could not load file or assembly 'Spring.Core, …'

和自甴很熟 提交于 2019-12-11 06:59:43
问题 Below follows the error generated: Server Error in '/' Application. -------------------------------------------------------------------------------- Could not load file or assembly 'Spring.Core, Version=1.3.1.40711, Culture=neutral, PublicKeyToken=65e474d141e25e07' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Description: An unhandled exception occurred during the execution of the current web

Fluent NHibernate Order by Property in related Entity

江枫思渺然 提交于 2019-12-11 06:59:22
问题 I have 2 tables in my database: CREATE TABLE [items]( [item_id] [int] IDENTITY(1,1) NOT NULL, [item_name] [varchar](50) NOT NULL, [group_id] [int] NOT NULL ) CREATE TABLE [itemgroup]( [group_id] [int] IDENTITY(1,1) NOT NULL, [group_name] [varchar](50) NULL ) and here are mapping classes for these entities: public class ItemMap : ClassMap<Item> { public ItemMap() { Table("items"); Id(x => x.Id).Column("item_id"); Map(x => x.Name).Column("item_name"); References(x => x.ItemGroup).Column("group

Search for equivalent Fluent Nhibernate Mapping - Mapping Map as Dictionary

谁说我不能喝 提交于 2019-12-11 06:39:55
问题 I search for a equivalent Fluent Mapping for the following Attribute-based mapping in NHibernate 2.1 [Class(typeof(Article), Table = "ARTIKEL")] public class Article { [Id(0, Name = "Id", Column = "Id")] public virtual int Id { get; set; } [Map(0)] [Key(1, Column = "MainArticle")] [IndexManyToMany(2, ClassType = typeof(Article), Column = "ChildArticle")] [Element(3, Column = "Amount", NotNull = true)] public virtual IDictionary<Article, decimal> Bundle { get; set; } } I am not able to get a

How can I map a nullable enum in NHibernate?

冷暖自知 提交于 2019-12-11 06:37:59
问题 I have been unable to persist a nullable enum using NHibernate with Fluent NHibernate configuration. NHibernate attempts to save a string representation of the enum and I get the error System.Data.SqlClient.SqlException: Conversion failed when converting the nvarchar value 'VGS' to data type tinyint. The property is defined as public virtual CostContributor? ReplacementContributor { get; private set; } and the mapping is Map(x => x.ReplacementContributor).CustomTypeIs(typeof(CostContributor?)

converting to Fluent NHibernate sessionmanager

坚强是说给别人听的谎言 提交于 2019-12-11 06:32:43
问题 I am changing my application to use Fluent NHibernate. I have created my Fluent mapping files and have now moved onto configuring my Session Manager. Currently, I use the following code - private ISessionFactory GetSessionFactory() { return (new Configuration()).Configure().BuildSessionFactory(); } Along with my hibernate.cfg.xml - <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory> <property name="connection.provider"

NHibernate - first query is painfully slow

徘徊边缘 提交于 2019-12-11 06:29:09
问题 Database table (PostgreSQL) containing 10000 rows: CREATE TABLE test ( id bigserial NOT NULL, text text, CONSTRAINT test_pkey PRIMARY KEY (id) ) Classes: public class Test { public virtual int ID { get; set; } public virtual string Text { get; set; } } public class TestMap : ClassMap<Test> { public TestMap() { Table("test"); Id(x => x.ID, "id"); Map(x => x.Text, "text"); } } Here is how I query database: using (ISession session = SessionBuilder.OpenSession()) { Stopwatch s = new Stopwatch();

How to build Fluent NHibernate?

◇◆丶佛笑我妖孽 提交于 2019-12-11 06:27:27
问题 I want to take a look on Fluent NHibernate but unfortunately I cannot find any information on how to build it from the sources. Maybe someone can help me? What tools I need for building it? 回答1: The Build.bat file only contains one command, and that is "rake" which is Ruby Make. This runs rake in the current folder, using the file "rakefile" to build the project. So, you need rake to be able to build using the bat file. If you are using Windows, you can install Ruby by using the Ruby