nhibernate

NHibernate mapping multiple relationships between two tables

你。 提交于 2019-12-25 02:31:09
问题 I have an irritating problem. I've got two objects which are related on two different columns. The relationships are the same (both one-Many) and the structure is as follows BRAND table ID Name [Other stuff] CATEGORY table ID Name BrandID (FK to Brand. Navigation Name Brands) DynamicBrandID (FK to Brand. Navigation Name DynamicBrands [Other stuff] But no matter what I try, I can't get this to work in NHibernate. The HBM files look like they've generated correctly for both objects but no

fluent nhibernate - Many to Many relationship with attribute on relationship

大兔子大兔子 提交于 2019-12-25 02:14:09
问题 I have my code working, but I'm getting 2 extra columns in the table/ddl, to represent a Many to Many relationship, ~~but~~ with attributes (scalars) on the relationship. I am using 1.2.0.712 (FluentNHibernate.dll) 3.1.0.4000 (NHibernate.dll) Entities: public partial class Employee { public Employee() { CommonConstructor(); } private void CommonConstructor() { this.MyEmployeeToJobTitleMatchLinks = new List<EmployeeToJobTitleMatchLink>(); } public virtual Guid? EmployeeUUID { get; set; }

Nhibernate setting query time out period for commands and pessimistic locking

霸气de小男生 提交于 2019-12-25 02:11:19
问题 I wish to specify a specific command timeout (or LOCK_TIMEOUT) for an SQL and once this time out is reached an exception (or alert) has to be raised in nHibernate. The following is an example pseudo-code what I have written: using (var session = sessionFactory.OpenSession()) { using (var sqlTrans = session.BeginTransaction()) { ICriteria criteria = session.CreateCriteria(typeof(Foo)); criteria.SetTimeout(5); //Here is the specified command timout, eg: property SqlCommand.CommandTimeout Foo

Multiple UnitOfWorks, ISession and repositories

假如想象 提交于 2019-12-25 02:03:36
问题 Do you know a good example somewhere for this? What I would like is the following: using(IUnitOfWork uow = UnitOfWork.Start()) { repositoryA.Add(insanceOfA); repositoryB.Add(instanceOfB); uow.Commit(); } But this case is too ideal, because what I also want is multiple UnitOfWorks (per presenter in most cases, and this is not for a web app). In that case, how will repositories know which UnitOfWork to use if I don't give them that explicitly like repository.UnitOfWork = uow; My goal is to have

How to bind a series of columns into a collection with NHibernate

血红的双手。 提交于 2019-12-25 01:52:39
问题 Please believe me when I say I understand this isn't the "right" way to do this. File this under large-complex-legacy-system questions. We have tables describing OCR'd data of documents. Each document type has its own table. Each table is generated based on the types of fields it expects. So have a schema which looks a bit like this: Table: DocumentTypes Field: Id Field: Prefix Table: DocumentFields Field: Id Field: DocId Field: Name And we would generate tables like: Table: Type1_Data

Serialize list of objects with JSON.NET in C#

不羁的心 提交于 2019-12-25 01:45:47
问题 I have a List that looks like: List<Product> products = new List<Product>(); Product p1 = new Product(1, "Apple", new Description("Red Apple")) Product p2 = new Product(2, "Banana", new Description("Yellow Banana")) products.Add(p1); products.Add(p2); A product looks like this: //Product model public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Description descriptions { get; set; } //Description model public string description { get; set } Now I want

Why does NServiceBus Saga timeout request use wrong Saga ID?

筅森魡賤 提交于 2019-12-25 01:44:29
问题 My Saga message handler (configured as ISagaStartedBy) requests a timeout message for every message received. Debugging through a few messages at a time, I've found the time the first time the handler is fired, the saga ID sent to the timeout manager is different to the one a) persisted in the database and b) the saga ID sent in subsequent messages. The subsequent messages all send the Saga ID from the database. Here's the handler: public void Handle(PaymentRequested message) { int

How to get nhibernate to cache tables referenced via many-to-one - is my config correct?

 ̄綄美尐妖づ 提交于 2019-12-25 01:38:02
问题 I've been trying to get this working for a while now with no luck. I want to enable the 2nd level cache to prevent fetching from some lookup tables. I set up my configuration in code cfg = new Configuration(); cfg.Properties[NHibernate.Cfg.Environment.ConnectionProvider] = "NHibernate.Connection.DriverConnectionProvider"; string connectionString = connection.ConnectionString; cfg.Properties[NHibernate.Cfg.Environment.ConnectionString] = connectionString; cfg.Properties[NHibernate.Cfg

Why does NServiceBus Saga timeout request use wrong Saga ID?

不想你离开。 提交于 2019-12-25 01:29:00
问题 My Saga message handler (configured as ISagaStartedBy) requests a timeout message for every message received. Debugging through a few messages at a time, I've found the time the first time the handler is fired, the saga ID sent to the timeout manager is different to the one a) persisted in the database and b) the saga ID sent in subsequent messages. The subsequent messages all send the Saga ID from the database. Here's the handler: public void Handle(PaymentRequested message) { int

How to compare datepart Month using Nhibernate Criteria?

对着背影说爱祢 提交于 2019-12-25 01:28:53
问题 This is my code: public IList<VotacaoPlenario> RetornarVotacao(int mesInicio, int anoInicio) { DetachedCriteria criteria = DetachedCriteria.For<VotacaoPlenario>(); if (anoInicio > 0) { criteria.Add(Expression.Eq("YEAR(Data)", anoInicio)); } IList<VotacaoPlenario> votacao = criteria.GetExecutableCriteria(Session).List<VotacaoPlenario>(); return votacao; } } In my table de field Data is Datime i'm need to compare with the variable anoInicio which is int How can i do that? 回答1: The solution here