Problem is simple I have two classes mapped with fluent nhibernate :
public class A: EntityBase {}
public class B: EntityBase
{
public virtual A A_Something {get;set;}
}
with EntityBase class providing only Key property. Now i want to map them and configure my db. So here are mappings
public class AMap : DomainEntityBase<A>
{
pu...
Our entities have a group of common properties. In order to reduce repetitive mapping, I created a base ClassMap that maps the identities and common properties. For each entity's ClassMap I just subclass the base and it works great. For a new project we are also letting NH generate the DB schema for us. The issue is, the order of the col...
Hi, my application has the following entity:
public class User
{
public virtual int UserID { get; set; }
public virtual Membership LatestMembership { get { return Membership.First(); } }
public virtual IList<Membership> Membership { get; set; }
public User()
{
Membership = new List<Membership>();
}
}
W...
I'm learning to use NHibernate validator and it's Fluent API (Loquacious).
I have noticed is that I can't set an integer property or nullable int property (int?) to be not nullable. Well, why not?
In a database, an integer column can have null values. Even worse, when I generate DDL using SchemaExport, the integer column wont be pickin...
Hi, I have this scenario:
public class Survey : EntityBase
{
public virtual string Name { get; set; }
}
public class Response : EntityBase
{
public virtual string Name { get; set; }
public virtual Survey Survey { get; set; }
}
public class SurveyMap : ClassMap<Survey>
{
public SurveyMap()
{
this.Id(e => e.I...
I need some tutorials on how to get started with nHibernate and Fluent nHibernate. I'm coming from an Entity Framework background (which seems easier to use). I've tried sites like http://www.summerofnhibernate.com/ to get a grasp on nHibernate itself, but it seems outdated.
I'd like to generate a mapping of my database tables (al la En...
So as usual I have an issue with ria service + nhibernate. The question is how to make an entity property
, mapped using “references”, visible on the client side. The problem is that when you load an entity
without this field and try to save it , then missing values are updated as NULL inside db. Here’s class schema:
public class A
{...
I have a class, Document and several sub-classes (Invoice, PurchaseOrder, etc). I've added a discriminator to Document like so:
public class DocumentMapOverride : IAutoMappingOverride<Document>
{
public void Override(AutoMapping<Document> mapping)
{
mapping.DiscriminateSubClassesOnColumn("DocumentType");
}
}
My un...
I'm getting the "Save unsaved transient entities" error in NHibernate. I have an aggregate root, neighborhood that contains addresses and person, here's some quick pseudo code to explain the relationship:
public class Neighborhood {
public virtual int Id { get; set; }
public virtual IList<Address> Addresses { get; set; }
}
public...
Hi all. I have a table http://img36.imageshack.us/i/beztytuuszxq.png/ and mapping:
public class CategoryMap : ClassMap<Category>
{
public CategoryMap()
{
Table(FieldNames.Category.Table);
Id(x => x.ID);
Map(x => x.Name).Not.Nullable();
Map(x => x.ShowInMenuBar).Not.Nullable();
References(x...
Hi,
I have two classes mapped using fluent NHibernate - User and a UserRoleAssignment. An User has many UserRoleAssignments. Here's the relevant map for user:
HasMany(x => x.Roles)
.Table("UserRoleMap")
.Cascade.SaveUpdate();
And for UserRoleAssignment:
Map(x => x.User_Id);
As you can see, I'm only referencing from User to UserRol...
hi guys,
i'm new to nhibernate so maybe the response depends on my lack of knowledge.
I created these two tables:
(sorry for italian language, i hope you can understand withouth any problems).
Then, i have these object in my model:
[Serializable]
public class Profilo
{
public virtual int Id { get; set; }
public virtual stri...
I have an application using Fluent NHibernate on the server side to configure the database. Fluent uses Lazyloading as default, but I explicitly disabled this as this gave me problems when sending the objects to the client side. Obviously the client can't load the objects lazily as it doesn't have access to the database.
Now I try reen...
I use a Where clause in my FluentNHibernate mappings as follows:
public class FooMap : ClassMap<Foo>
{
public FooMap()
{
Table("MySchema.Foos");
Where("Deleted = 0");
etc etc
}
}
This where clause gets appended to the SQL when I load individual Foo instances through session.Load<Foo>(1) and when I use LINQ queries. H...
I'm building an ecommerce site using S#arp Architecture.
I'm trying to map a hierachy of categories and retrieve the top level categories.
I'm using NHibernate.Linq for this.
I have the following entity:
public class Category : Entity
{
#region Properties
[DomainSignature]
[NotNullNotEmpty]
public virtual string Name {...
I have a problem with nHibernate projections. I don't even know if what I'm attempting can be done but if any nHibernate experts can help me I'd be grateful.
I'm using nHibernate criteria to query a database and I'm returning the result projected to a different (slimmed down) object.
I get a list of returns like
Id CompanyId Descr...
Hi.
I'm using ASP.NET MVC with NHibernate and Fluent.NHibernate Maps.
I would like to know how to map the classes on Fluent and to create the database tables on my MySQL:
public class AgenteDeViagem {
public virtual int Id { get; set; }
public virtual string Email { get; set; }
public virtual AgentePessoa AgentePessoa { ge...
I'm looking for some ideas on how other people are managing the following situation - I've got some ideas but they seem a little messy and I can't help thinking I'm missing something.
Here's the situation:
You're using NHibernate with Fluent NHibernate for mappings.
You have an application in production with a database with live data
...
I'm using Fluent NHibernate to map a a class that has a collection of strings like this:
public class Foo {
public virtual ICollection<string> Strings { get; set; }
}
public class FooMap : ClassMap<Foo>
{
public FooMap() { HasMany(f => f.Strings).Element("SomeColumnName"); }
}
When I write a unit test using the PersistenceSpe...
HI,
I was wondering if any one else had had a problem with VS2010 MVC 2 projects not being able to automaticly create a strongly typed view after doing a fluent mapping?
When trying to do the mapping VS2010 doesnt show the Entities in the drop down and even if i manually put the class in it doent auto build the view .
Cheers
Dan
...