I'd like to program against interfaces when working with NHibernate due to type dependency issues within the solution I am working with.
SO questions such as this indicate it is possible.
I have an ILocation interface and a concrete Location type. Will the following work?
HBM mapping:
<class name="ILocation" abstract="true" table="IL...
You can specify the namespace and assembly to use types from at the top of HBM files:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyCorp.MyAssembly" namespace="MyCorp.MyAssembly.MyNamespace">
Can you use types from multiple assemblies / namespaces within the same mapping file, and if so what is the syntax for doing...
I have an interface IUserLocation and a concrete type UserLocation.
When I use ICriteria, specifying the interface IUserLocation, I want NHibernate to instantiate a collection of the concrete UserLocation type.
I have created an HBM mapping file using the table per concrete type strategy (shown below). However, when I query NHibernate ...
I need a Fluent NHibernate mapping that will fulfill the following (if nothing else, I'll also take the appropriate NHibernate XML mapping and reverse engineer it).
DETAILS
I have a many-to-many relationship between two entities: Parent and Child. That is accomplished by an additional table to store the identities of the Parent and C...
I am trying to map an entity in NHibernate, that should have an Updated column. This should be the DateTime when the entity was last written to the database (either created or updated). I'd like NHibernate to control the update of the column, so I don't need to remember to set a property to the current time before updating.
Is there a b...
In my MySQL database, I have the following column type.
Field | Type | Null |
----------------------------------
Column_priv | set('Select','Insert','Update','References') | No |
And I cannot figure out what to map this to.
Can anyone tell me how I can map this to something?
...
Hi
I'm using Fluent Nhibernate, i need to create mappings for 2 tables:
Simplified, they look like this:
TAXI
(
Id int primary key
Name varchar
)
ORDER
(
Id int primary key
RedirectedFrom int foreign key on TAXI.Id
RedirectedTo int foreign key on TAXI.Id
)
So, two foreign keys from table TAXI refer to table ORDER
Q:
Is tha...
Hi,
I have an object as follows
Public Class Bin
Public Property Id As Integer
Public Property Name As String
Public Property Store As Store
End Class
Public Class Store
Public Property Id As Integer
Public Property Bins As IEnumerable(Of Bin)
End Class
I have a unique constraint in the database on Bin.Name and ...
I'm using NHibernate (fluent) to access an old third-party database with a bunch of tables, that are not related in any explicit way. That is a child tables does have parentID columns which contains the primary key of the parent table, but there are no foreign key relations ensuring these relations. Ideally I would like to add some forei...
I've got an application that keeps track of (for the sake of an example) what drinks are available at a given restaurant. My domain model looks like:
class Restaurant {
public IEnumerable<RestaurantDrink> GetRestaurantDrinks() { ... }
//other various properties
}
class RestaurantDrink {
public Restaurant Restaurant { get; ...
Hi!
Basically, I have an ImageMetadata class and an Image class, which derives from ImageMetadata. Image adds one property: byte[] Content, which actually contains binary data.
What I want to do is to map these two classes onto one table, but I absolutely do not need NHibernates' inheritance support to kick in. I want to tailor FNH Aut...
I've got a class hierarchy mapped using table-per-subclass, and it's been working out great:
class BasicReport
{
...
}
class SpecificReport : BasicReport
{
...
}
With mappings:
<class name="BasicReport" table="reports">
<id name="Id" column="id">...</id>
<!-- some common properties -->
</class>
<joined-subclass name="Sp...
In FluentNHibernate when should I use ClassMap and when IAutoMappingOverride<Entity> for my EntityMap classes.
public class PostMap : ClassMap<Post>
{
public PostMap()
{
...
}
}
vs
public class PostMap : IAutoMappingOverride<Post>
{
public void Override(AutoMapping<Post> mapping)
{
...
}
}
...
I have two classes (Parent, Child) that have a many-to-many relationship that only one end (Parent) knows about. My problem is that when I delete a "relation unaware" object (Child), the record in the many-to-many table is left.
I want the relationship to be removed regardless of which end of it is deleted. How can I do that with Fluent...
Okay, so yesterday I managed to get the latest trunk builds of NHibernate and FluentNHibernate to work with my latest little project. (I'm working on a bug tracking application.) I created a nice data access layer using the Repository pattern.
I decided that my entities are nothing special, and also that with the current maturity of ORM...
If I have a field in the db which stores a set of comma separated strings (says tags), how can I instruct fluent Nhibernate to pick it up at List<string>()
e.g.
Public IList<string> Tags {get; set;}
Db field values:
Mvc, .net, FNH
...
I have a rather large inheritance hierarchy in which some of the subclasses add very little and others add quite a bit. I don't want to map the entire hierarchy using either "table per class hierarchy" or "table per subclass" due to the size and complexity of the hierarchy. Ideally I'd like to mix mapping strategies such that portions ...
I'm looking to create a many to many relationship using NHibernate. I'm not sure how to map these in the XML files. I have not created the classes yet, but they will just be basic POCOs.
Tables
Person
personId
name
Competency
competencyId
title
Person_x_Competency
personId
competencyId
Would I essentially create a List in each POC...
Hi
In this article Ayende describes how to map a single domain model to multiple physical data models. Is it possible to extend this principle such that the mapping can chosen dynamically?
So for example, imagine we had an entity that could be written to the same physical schema in three ways depending on its current status, and lets a...
I have to describe interconnection between objects.
public class Entity
{
public string Name {get;set;}
public IList<Entity> Connections {get;set;}
}
How can i persist this?
I add another layer of complexity: querying on a specific date a connection between two entities can't be already defined. So probably I need a support t...