fluent-nhibernate

Delete an item from many-to-many relationship

纵然是瞬间 提交于 2019-12-06 13:02:36
I've following mapping for two tables having a Many-to-Many relationship between them. How do I delete an entry from the mapping table, which is 'TB_EMAIL_GRUPO_ARQUIVO' in my case? I just need to delete the data from this "joining" table and I don´t need to delete it from the "parent tables". GrupoModulo public GrupoModuloMap() { Schema(Const.SCHEMA); Table(Const.TB_EMAIL_GRUPO_MODULO); CompositeId() .KeyReference(x => x.Grupo, Const.ID_GRUPO) .KeyReference(x => x.Modulo, Const.ID_MODULO); Map(x => x.GrupoId).Column(Const.ID_GRUPO).ReadOnly(); Map(x => x.ModuloId).Column(Const.ID_MODULO)

NHibernate or FluentNHibernate or ActiveRecord?

随声附和 提交于 2019-12-06 11:53:20
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 productivity dramatically. However, I do not like the idea of adding attributes to my CSharp classes. After all, my class should NOT have any knowledge of database relationships. By using ActiveRecord will bind my nicely separated classes to ActiveRecord, and

What to be aware of when upgrading NHibernate from 1.2 to 3.2?

时光毁灭记忆、已成空白 提交于 2019-12-06 11:45:55
问题 Question says it all. Working with an old codebase that is using NHibernate 1.2. What do I stand to gain, and what will I lose, or experience in pain, as part of this upgrade? Is the total effort worth the benefit, and if so, what are those benefits? And while I'm at it, would it make sense to just move to Fluent NHibernate? 回答1: This really depends on what nhibernate functions you are using. Take the release nodes and see if anything is in there you are using. Most functions are still

How do I update the primary key using nhibernate

旧巷老猫 提交于 2019-12-06 11:27:23
The primary key for one of my tables is a string. THe string is a code which i would like to update at some point of time. How can I do this in nhibernate. Please note there is a foreign key connected to this column which I need to cascade updates to. For the sake of discussion let us assume my mapping is as below public class Code { public virtual string Id { get; set; } public virtual string Name { get; set; } public class CodeMap : ClassMap<Code> { public CodeMap() { Table("BusinessCode"); Id(x => x.Id, "Id"); Map(x => x.Name, "Name").Nullable(); } } } public class Data { public virtual int

Fluent nhibernate automapping collection

二次信任 提交于 2019-12-06 11:14:06
问题 I am trying to map my collections with FNHib automapping. The problems that I want to solve are: 1) I want all my collections in the project to be mapped via private field. How can I say that globally? 2) Is there any way to automap bidirectional relationship without explicitly overriding each of my entities. class OrganizationEntity example: private ISet<> _collectionWarehouse; public virtual IEnumerable<WarehouseEntity> CollectionWarehouse { get{return _collectionWarehouse; } set{

SqlDateTime overflow using NHibernate

对着背影说爱祢 提交于 2019-12-06 10:49:06
I persist my objects using NHibernate in the database the App object have a property defined: public virtual DateTime ReleaseDate { get; set; } in the mappingClass: Map(x => x.ReleaseDate).Not.Nullable(); which in the sqlServer 2008 its dataType is dateTime and is not nullable. for the first Time it saves to database with no error. but after updating app info I encounter SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. but the app release date is a valid dateTime : 2/16/2014 2:21:58 AM and it's not null. so Im confused why this exception raise? ist<App>

Fluent NHibernate mapping a CompositeId and Querying with SetProjection

一笑奈何 提交于 2019-12-06 10:13:10
I have two tables (Section and SectionList) that are related by a many to many table (Membership). Since there is an extra property in the many to many table, i have to break it out into its own entity: public MembershipMap() { UseCompositeId() .WithKeyReference(x => x.Section, "SectionId") .WithKeyReference(x => x.SectionList, "SectionList"); Map(x => x.Status); } And SectionList is mapped as follows: public SectionListMap() { Id(x => x.Id) .WithUnsavedValue(0); HasMany(x => x.Memberships) .Inverse() .Cascade.AllDeleteOrphan(); } The relationship seems to work fine, except for when I try to

Fluent NHibernate mappings for localization

感情迁移 提交于 2019-12-06 10:09:37
I am trying to build a Database from NHibernate mappings and have run into a problem. I have many classes with localized string values: public class MyClass1 { public virtual int Id { get; set; } public virtual ShortString Name { get; set; } public virtual LongString Description { get; set; } } public class MyClass2 { public virtual int Id { get; set; } public virtual ShortString Name { get; set; } public virtual LongString Description { get; set; } } and Languages like public class Language { public virtual string Code { get; set } public virtual string Name { get; set } } My ShortString and

NHibernate - filtering out results based on child-property

旧街凉风 提交于 2019-12-06 08:47:43
问题 I have this code fetching all enabled Groups with their children. The problem I have is that the children can also be disabled but I can't get fluent nhibernate to only fetch groups where all childrens are enabled. I assume this is possible but how? public class Group { public bool IsDisabled { get; set; } public string Description { get; set; } public ICollection<ChildType> Children { get; protected set; } } public class ChildType { public bool IsDisabled { get; set; } public string

Use a derived class in fluent nHibernate

青春壹個敷衍的年華 提交于 2019-12-06 08:37:09
问题 I have two tables which share common fields. Rather than re-map all of these I would like to have a base class with the common fields. For POCO this is simple: class Base { public string commonField {get;set;} } class Derived : Base { public string specificField {get;set;} } class OtherDerived : Base { public string specificOtherField {get;set;} } Note that there is no such thing as a table for "base". It just holds lots of common fields shared among several tables. Yes, I know this is not