I am using nHibernate 2.1.2.4000 with Asp.Net 4.
I also have a mapping defined for an Entity. The mapping also defines a filter named CultureCode.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Demo.EntityCore.Domain.Option, Demo.EntityCore" table="tbl_options">
<...
I'm working with an existing database that has the following structure. Changing the database schema is a last resort.
Products
Id
Name
ParentProducts
ParentId
ChildId
I don't want an entity for ParentProducts, I have the following for the children property (still need to test it, but that's the concept).
<bag name="Chil...
When you create a criteria, you can add Restrictions that apply to a property. There are 2 ways of creating a Restriction:
Restrictions.Eq(string propertyName, object value)
or
Restrictions.Eq(IProjection projection, object value)
Thing is, I don't feel comfortable passing property names as strings, since if they ever change, my projec...
hi, i have readonly VIEWs in an existing Database and i'd like to get them with FHN. i tried mapping it the following way:
public class HhstMap : ClassMap<Hhst>
{
public HhstMap()
{
Table("HHST");
ReadOnly();
Id();
Map(x => x.Hkz);
Map(x => x.Kapitel);
Map(x => x.Titel);
...
What is the new SetAttribute() in FNH mapping? I need to set my discriminator value on subclass because String is not preferred - old post
with NH 2.1.2.4000, FNH 1.1.0.689
public class BaseBuildingMap : ClassMap<BaseBuilding>
{
public BaseBuildingMap()
{
Id(x => x.Id);
DiscriminateSubClassesOnColumn<int>("Build...
I have a class which I would like to map as a component onto any table which contains it:
public class Time
{
public int Hours { get; set; }
public int Minutes { get; set; }
public int Seconds { get; set; }
}
I would like to store this class as a bigint in the database - the same as how TimeSpan is stored but my class has ...
Suppose I have the following tables:
Company Person Address
----------------------------------------------------------------------------
Id (PK) Id (PK) Id (PK)
Name CompanyId (FK) CompanyId (FK)
AccessType AddressType
Corresponding t...
Hi, i have the following db structure:
Users:
- UserID
- UserName
- FirstName
- LastName
...
UsersLog:
- UserLogID
- UserID
- UserName
- FirstName
- LastName
...
- DateCreated
The log table simply inserts a record against the user everytime an insert or edit is made. The reason i have the log table is that when an order is submitted...
I have a child table containing an id to the parent. This is a one to one mapping, but the child table might be missing values. I'm having problems mapping this without getting an error though... I've tried several things; mapping the same column, having distinct properties etc..
Parent table
int id
Child table
int parentid
Paren...
Consider the following simplified scenario:
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
// restricted
public string SocialSecurityNumber { get; set; }
// restricted
public string MothersMaidenName { get; set; }
}
So, in the application, many users can view Person data....
I am working with nHibernate, and trying make sense of bag collections. My data structure is relatively straight-forward...
Entry:
<class name="Entry">
<id name="id" column="EntryId">
<generator type="guid.comb"/>
</id>
<property name="Name" column="Name"/>
<bag name="Results" table="Results" cascade="all">
<key column="Ent...
How can I map following queries using Fluent NHibernate (entity, mapping class etc..), the employee ids are stored in identifier tables. Person table contains employee information and non-employee information.
SELECT p.Id, p.FirstName, p.LastName
FROM Person p
UNION ALL
SELECT e.Id, e.FirstName, e.LastName
FROM Employee e
...
I am having an issue with saving entities with one-to-one relationships. I just want to save the parent entity and have the child be save aswell but I am having to save both separately.
This is an example of what I am having to do, otherwise the child is not saved.
var session = SessionProvider.OpenSession.Session;
using (...
I have a bit of an odd scenario where I have a table that references a view that contains rows which are user-specific. The view has a unique row ID, but it is never used to reference the item. Instead a unique value is derived from a combination of a client ID, user ID, and an object key.
public BarMap()
{
Table(Datab...
Hi,
I have the following two tables:
Package
id
ClientPackage
id
clientNumber
packageId
The thing is that I do not have a Client table in this database (it resides in another database). Is there a way that I can create a Client mapping to a Client model which just consist of distinct "clientNumber" from the ClientPackage table whil...
Hello,
we're working on a large windows forms .net application with a very large database. currently we're reaching 400 tables and business objects but thats maybe 1/4 of the whole application.
My question now is, how to handle this large ammount of mapping files with nhibernate with performance and memory usage in mind.
The business ...
Hi,
I have a class School and another class Teachers. now every school can contain m Teachers and one Teacher may be part of more than one school. But in the Teachers class I dont want a property that tells me which Schools a teacher is part of.
Thus,
public class School
{
public virtual int Id {get;set;}
public virtual string Name {g...
Hi,
Im playing around with NHibernate 3 alpha but struggling to set up my SessionFactory.
I have the following:
var config = new Configuration().Configure();
_sessionFactory = config.BuildSessionFactory();
However, in the provided dlls with the 3 alpha download there are no provided proxy factory classes. Ie NHibernate.ByteCode.Ca...
Is this possible in fluent nhibernate having multiple mappings for one table? Lets suppose i have a Users table.
Once i want it to be apped exactly like in file UserMap1.cs, and some times I would rather prefer mapping from UserMap2.cs.
I don't need to switch configurations while app is running. I just have to choose a proper one at th...
Hi
I am presently trying to use NHibernate on a project where I do not have permissions to CREATE TABLE in SQL 2005.
I keep getting a mapping error, and my assumption is that I do not setup the table by generating it. Is it fair of me to assume that NHibernate can only map successfully with tables that were generated by its tool?
If n...