I have columns in my Oracle db that I use a TrimmedStringUserType for to trim text from char(x) columns.
The db has natural keys in many tables, so I'm using Assigned Ids. Many of these are char(x) columns. How, using Fluent NHibernate (or even in the xml mapping) would I use this usertype to ensure that the Ids are trimmed?
...
Is there a way of writing an NHibernate mapping so that you can have an entity that is composed of fields from different DB tables?
For Example is I have a Person and Address table, I want address fields to appear in my person object.
I want an entity like this:
public class person
{
public virtual Guid Key{get; set;}
public v...
Example:
public class ContactMap : ClassMap<Contact>
{
public ContactMap()
{
WithTable("ida_contact");
Id(x => x.ID, "ida_contact_id").WithUnsavedValue(0).GeneratedBy.UuidHex("");
Map(x => x.FirstName);
Map(x => x.Surname);
Map(x => x.Address1, "dm_address_1");
Map(x => x.Address2,...
How do I "turn on" cascading saves using AutoMap Persistence Model with Fluent NHibernate?
As in:
I Save the Person and the Arm should also be saved. Currently I get
"object references an unsaved transient instance - save the transient instance before flushing"
public class Person : DomainEntity
{
public virtual Arm LeftArm { g...
I have 2 entities Person and Address, Person has one Address.
EDIT: The Address already exists, Im just wanting to save the foreign key.
When I do this:
PersonDTO person = new PersonDTO();
person.Age = "Bob";
person.Address = new AddressDTO {Key = 123};
Save(person);
I get this exception:
Cannot insert the value NU...
Please help me - I'm new to NHibernate and I cannot seem to find what I'm looking for.
I have two tables in a database: Fund and FundBalance. A Fund can have many FundBalances and a FundBalance has only one Fund.
In C#, there is only the FundBalance class. Columns from the Fund table joined with columns from the FundBalance table need ...
I'm using Fluent NHibernate for my mappings and the SchemaExport class to the database schema.
Is it possible with NHibernate to set a default value for a property/column in the generated database schema?
...
I have googled and looked around does anyone know of any hidden gems out there that is not in first couple pages of a google search....
...
Hi,
I'm getting this weird ArgumentOutOfRangeException whenever I use the
PersitenceSpecification class for verifying an entity that has a
reference to a value object.
public class CatalogItem : DomainEntity
{
internal virtual Manufacturer Manufacturer { get; private
set; }
internal virtual String Name { get; pr...
I have a table that needs relations to 2 tables, according to ObjectType column.
For example if ObjectType=1 then column Object should point to TABLE1, and if ObjectType=2 then point to TABLE2.
Can I accomplish this in NHibernate mappings or as Fluent NHibernate?
If not will you suggest me using same Interfaces for both Table classes?...
I have two items A and B, which have a uni directional one-to-one relationship. (A has one B)
In the database these are represented by ATable and BTable, and they are linked together by ABTable. (From the database setup it appears there is a many-to-many relationship but there is not, it was done this way for normalization reasons).
...
Is it possible to generate table indexes along with the rest of the database schema with Fluent NHibernate? I would like to be able to generate the complete database DDL via an automated build process.
...
Title says it all.
From what I understand I need to end up with this
<property name="hibernate.generate_statistics">true</property>
on the session factory configuration, but I've no idea how to do that with fluent nhibernate.
Thanks
Andrew
...
I am trying to configure fluent nHibernate and have this code
Assembly mappingAssembly = Assembly.ReflectionOnlyLoadFrom("LibrarySample.Model.dll");
sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.ConnectionString(c => c
.FromAppSetting("ConnectionString"))
.ShowSql())
.Mappings(m => ...
I'm trying to configure nHibernate to use a MySql database. I found examples for mssql and sqlite but none for mysql.
So, how do I change this so it uses mysql:
Fluently.Configure().Database(
MsSqlConfiguration.MsSql2005.ConnectionString(
c => c.FromConnectionStringWithKey("ConnectionString")
)
)
.Map...
I am using: NHibernate, NHibernate.Linq and Fluent NHibernate on SQL Server Express 2008. I am selecting an entity using a predicate on a referenced property (many-one mapping). I have fetch=join, unique=true, lazy-load=false. I enabled the log4net log and when any such query executes it logs two identical SQL queries. Running the query ...
Hi there!
Looking for an answer on how to configure NHibernate to support my scenario, an many-to-many map with an objectified relation.
I have a colection of Person:s with relations to other Person:s. Each of the relations have an attribute specifying what type of relation they have. In an RDB this is done by using a many-to-many tabl...
I'm learning some Fluent NHibernate and I've run across the semi-awesome PersistenceSpecification class.
I've set it up in a unit test to verify my mappings and it works great. However, it leaves the record in the database when done. I tried throwing it in a transaction so I can rollback the changes but I get an error:
System.ObjectDis...
I have the following FNH mapping fragment:
HasManyToMany((c) => c.Plaintiffs)
.LazyLoad()
.WithTableName("invoicePlantiff")
.WithChildKeyColumn("PersonReferenceID")
.WithParentKeyColumn("invoiceID")
.FetchType.Join();
Which produces the following HBM:
<bag name="Plaintiffs" access="iServe.Design.CslaNHibernate...
I am not sure if this a problem with my Fluent configuration or some logic in my thinking.
Basically I have a Person class from which I have two inherited classes, Author and Borrower (it's a library system). The mapping I have is.
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Id(x => x.Id, "id");
...