The title may be confusing so ill try to elaborate. I have a business object that tracks time for either a manifest or an office. So in my database i have two columns, both are nullable, but only one can be not null. In my mapping i have
References(x=>x.Manifest, "ManifestId").Cascade.All();
References(x=>x.FieldOffice, "FieldOfficeId"...
I am using fluent nhibernate. This is code Loads an instance of type T from the DB based on its ID.
public T GetById(IdT id, bool shouldLock)
{
T entity;
if (shouldLock)
{
entity = (T) NHibernateSession.Load(persitentType, id, LockMode.Upgrade);
}
else
{
entity...
I've got a simple phone directory app using Fluent NHibernate 1.1. In the app, a "Person" object has many "PhoneNumber" objects. I'm trying to delete a Person and I want to cascade deletes to PhoneNumbers. I set a convention of DefaultCascade.All() after reading this answer. However, attempting to delete the parent object still throws an...
Hello guys...
Can you help-me with that database :
I´m using Fluent NHibernate, but XML helps too...
My problem is with ProductPrice table...
Thanks
Paul
...
I have a set of entities that implement an interface:
public interface ILocalised
{
Culture Culture { get; }
}
For lots of complicated reasons I need to filter entities which do not have the correct culture after they are returned back from the DB (i.e. I can't use a Filter). My immediate thought was to create an interceptor that ...
We have Product, Category and ProductToCategory classes.
A product has many ProductToCategories, a category has many ProductToCategories.
Product includes this property
public virtual IList<ProductToCategory> Categories { get; set; }
ProductToCategory
public class ProductToCategory : Entity
{
public virtual Product Pro...
I can't find how Nhibernate feature described in Ayende's blog works with Fluent NHibernate.
As far as I understand, I can map pseudo-field which value is a result of any hql query. Is this correct? How this feature can be used with Fluent Nhibernate? I tried google, but unsuccessful. Code samples or links to them would be much apprecia...
I have a string property on an entity that I would like to mark as required. For example,
public class Product
{
public virtual string Name { get; set; }
}
In my mappings, I can declare Name as required (using Fluent NHibernate):
mapping.Map(x => x.Name).Required();
However, this only restricts the string from being null. If I ...
I'm sure this problem has been addressed before but I can't find a 'duplicate'. So the question is:
I have a bidirectional one-to-many association: document and comments.
The comments table has a foreign key (not nullable) pointing to documents table.
The classes are:
public class Document {
public virtual Guid Id {get; set;}
pub...
I have a project that is using Fluent NHibernate. When I try to use the DB2Configuration to connect to a DB2 database I receive the following error when trying to build the SessionFactory:
"The IDbCommand and IDbConnection implementation in the assembly IBM.Data.DB2 could not be found. "
The assembly that is included in my install of I...
I have 2 tables like this: (Please note the non-standard db schema naming)
table T_Pen
TP_ID
TP_PrimaryColorID
TP_SecondaryColorID
...
table E_Color
EC_ID
EC_ColorName
...
And I want to create a mapping of the 2 tables to a domain object Pen using Fluent NHibernate.
class Pen
{
PenID;
PrimaryColorName;
Seco...
I have pasted all the code below. The problem is when I try to save or update Town Entity,
County Title comes null and Model State becomes false. Could you suggest me a way to get complete county Object here while saving Town. Could you also suggest me better flent nHibernate mapping in this case, please?
I have following classes and m...
I've attached an IPreUpdateEventListener to nhibernate and not getting the results I expect (saving of a child object). This object has history attached to it and if certain things change, it needs to reflect this and save it, no big deal right? Given the entity as such -- assume ListOfHistory is newed up in a constructor ...
pub...
I've got an MVC web-project that's referencing a class-library-project that contains my Domain and Persistence tiers. I'm using nHibernate for my OR/M. Since I've got multiple databases to connect to, I'm initializing my session-factories by specifying the file-names:
var config = new Configuration().Configure(nHibernateCfgFileName)
...
Hell All,
** Solved as of now Please see Edit 2 and Edit 3 **
I am NHibernate Newbie- a week old but I though working with it will save me time on new project and not otherwise. I have been banging my head trying to get Nhibernate to save Parent - Child Collection to SQL server database.
My Class Map :
public class OrderMap : Clas...
Can't find it in the Internet.
If someone helps I'll appreciate it greatly!
...
I'm trying to get Fluent NHibernate to map a collection for me. My class definitions are as follows:
public abstract class Team
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
}
public class ClientTeam : Team
{
public virtual IEnumerable<Client> Clients { get; set; }
}
public class Client
...
I am using Nhibernate (I am a complete noob), and what I want to be able to do is copy an entity that is loaded from the database and save it with a new Id... has anyone run into this situation? Any help would be very appreciated.
...
Hello ,
I have already read other SO posts dealing with similar but none clarified what I wanted to do.
I have MyProduct Entity and MyItem Entity. Product is made up of MyItem(s) .same like order order line scenario.
MyProduct Will need to have value objects
public class Item : EntityBase
{
public Item()
{
}
publ...
Hello,
I am mapping my value Object Item as component withthe folowing mapping configuration
{
Table("Product");
Not.LazyLoad();
Id(x => x.Id, "id");
Map(x => x.Number, "number");
Map(x => x.Name, "name");
Map(x => x.Description, "description");
Map(x =...