nhibernate

FluentNhibernate HasMany with component

烂漫一生 提交于 2019-12-23 02:45:01
问题 i have this mapping: HasMany<ClassA>(ot => ot.AList) .Table("XPTO") .KeyColumn("IDXPTO") .Component(m => { m.Map(a=> a.X, "X"); m.Map(x=> x.Y, "Y"); }) .Cascade.AllDeleteOrphan(); i get an error saying that "refers to an unmapped class ClassA", but i shouldn't need to map it. i saw other examples in the internet with similar mappings and they don't have this problem... if i create a classMap for class A only with ID, then its works, but the data model will have 1 unecessary table for classA

How to propagate a parameter for joins in a ORM

我与影子孤独终老i 提交于 2019-12-23 02:36:48
问题 This is a sequel of a question I asked before. So far the strategy for Schema Evolution problem I'm trying to implement is Slowly changing dimension. The problem that I have now looks as following. Consider the following data model: class Bar { int id; int param; double x; double y; } class Foo { int id; int param; string name; string description; collection<Bar> bars; } class Delta { int id; int param; double rating; } class RootEntity { int id; int param; collection<Foo> foos; collection

Invalid index 13 for this SqlParameterCollection with Count=13

狂风中的少年 提交于 2019-12-23 02:18:26
问题 This exact title can be found in google or here at stackflow.com many times but the reason I am getting this error is like none of them: I have no problem in the unit test code but the exact same code in the application causes this issue. I wish it was because of a mapping issue. Here is my mapping: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="My.Domain" namespace="My.Domain"> <class name="My.Domain.ReportFormFlag, My.Domain" table=

NHibernate - Paging with ICriteria and optional ICriteria calls

半城伤御伤魂 提交于 2019-12-23 02:17:10
问题 I want to do something like this... return GetSession() .ToPagedList<Employee>(page, pageSize, x=> x.SetFetchMode(DomainModelHelper.GetAssociationEntityNameAsPlural<Team>(), FetchMode.Eager)); But I don't know how to pass this Func<ICriteria,ICriteria> into the ISession or ICriteria . I have a standard paging extension method and this extension method shall have an overload where I can pass additional ICriteria methods, so that I can additionally set up the FetchMode or something else.

How to Generate Castle ActiveRecord C# Classes for an Existing Database

允我心安 提交于 2019-12-23 02:05:46
问题 What is the best way to generate C# classes for use with Castle ActiveRecord and NHibernate given an existing database structure? Can you recommend any of the class generation tools or is it just less hassle to write the classes by hand? 回答1: If you only have a handful of tables with not many columns, it may be best to write your classes by hand. I wouldn't recommend hand writing many classes though if your database already exists. Active Writer may meet your needs: http://using.castleproject

Where should the transaction boundary be in a repository pattern?

我只是一个虾纸丫 提交于 2019-12-23 02:04:24
问题 I have a repository like so: public interface IRepository { void Save<T>(T entity); void Create<T>(T entity); void Update<T>(T entity); void Delete<T>(T entity); IQueryable<T> GetAll<T>(); } My question is, where should my transaction boundaries be? Should I open a new transaction on every method and commit it before returning? Or should it be around the entire repository so that the transaction is only committed when the repository is disposed/garbage collected? 回答1: Unit of Work is

nHibernate batch-size doesn't work

本小妞迷上赌 提交于 2019-12-23 01:50:23
问题 I've got a problem with batch-size in nHibernate(C# - VS 2012). I set "batch-size" in the collection and in the config, but it doesn't work. using (var s = OpenSession()) { using (var t = s.BeginTransaction()) { Parent parent = s.CreateCriteria(typeof(Parent)).List<Parent>().First(); Console.Write(parent.Children[0]); t.Commit(); } } nHibernate profiler shows that it takes all children at once (for example 1000 children), but it should take only 5. Parent.hbm.xml: <?xml version="1.0" encoding

NHibernate Mapping Exception

余生颓废 提交于 2019-12-23 01:44:05
问题 I am a newbie to NHibernate and am trying to use ORM with Sql Server 2012 my code is GazelleInfo.cs namespace WCG.Data.EntityObjects { using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel.DataAnnotations; using System.Data.SqlTypes; ///<summary> ///Class to access Gazelle Info Table ///</summary> public class GazelleInfo { public virtual int ID { get; set; } [Required(ErrorMessage = "Specialty Name is required.")] [Display(Name =

Missing support for ambient transactions in nhibernate?

元气小坏坏 提交于 2019-12-23 01:37:21
问题 I know NHibernate supports ambient transactions, because NHibernate sessions enlists in the ambient transactions while inside a transaction scope. However, there are some oddities, consider the following test: [Test] public void Transaction_RollsBackTransactionInsideOfAmbientTransaction_AmbientTransactionAborted() { // arrange ISessionFactory sessionFactory = SessionFactoryOneTimeInitializer.GetTestSessionFactory(); ISession session = sessionFactory.OpenSession();

NHibernate LINQ + PLINQ

家住魔仙堡 提交于 2019-12-23 01:11:13
问题 i've just started reading up on PLINQ and find it fasinating. I'm using NHib->Linq in my projects - does anyone know if there's any benefit/problems using PLINQ type queries with NHLinq? w:// 回答1: If you're trying to parallelize several NHibernate queries with PLINQ, keep in mind that NHibernate's ISession is not thread-safe. You have to use a new ISession for each step of the PLINQ loop, since each step can potentially run in another thread. If you're trying to use PLINQ constructs within a