Lets say i have this database design:
Items
Id
Name
Desc
ItemTags
ItemId
TagId
Tags
Id
Tag
And i want to map it to the following class
class Item
int Id
string Name
string Desc
IList<string> Tags
Please note that I don't want to declare class Tag, i just want the Item class to have list of strings that repre...
Hi
I'm getting a strange NHibernate exception when I try and create a SessionFactory. I've narrowed down the exception 'Unable to cast object of type 'NHibernate.Mapping.Bag' to type 'NHibernate.Mapping.IKeyValue' to the following mapping on the Company object:
<bag name="Images" cascade="none">
<key column="CompanyId" property-ref...
I've got a many-to-many relationship which I try to fetch eager:
*.CreateCriteria(typeof(Class1))
.SetFetchMode("Class2", FetchMode.Eager)
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.SetFirstResult(20)
.SetMaxResult(10)
.List<Class1>();
I'd like to have rows 20-30 returned, but instead I've got 12-18. Why? Becaus...
Hi,
I am trying to build a messaging system and for this i have the table definition below
Message
Id
From
To
Body
ParentId // Subcollection, i want to get Asnwers (Message.ParentId== Message.Id)
IsRead
and i have this in the Message.cs
IList<Message> Answers;
I have tried this but it gives me all the messages and all the answers...
Lets say we have an Employee entity composed of a few other entities, such as a one-to-many addresses and contacts, and a few fields (name, age, etc). We mapped this entity out and can use it just fine, saving each piece out into "Employee", "EmployeeAddresses", and "EmployeeContacts" tables.
However, we use pretty much all of this empl...
What is NHibernate HQL's Equivalent to T-SQL's TOP Keyword?
Also what is the non-HQL way for saying give me the first 15 of a class?
...
I have a Vessel object that has a one-to-many relationship with a
VesselDetail object. When I add a VesselDetail object to the Vessel object and try to save the Vessel object, it seems NHibernate does not add the foreign key when inserting the VesselDetail object.
Where am I going wrong here ? I just cannot figure it out.
Error messag...
Hello,
After implementing Nh.Burrow in an asp.net application, I was wondering how to do it for a WCF-service.
My first idea was to put a the BurrowFramework().InitWorkSpace(); in each method and set the InstanceContextMode to per Call on these methods. Now I have two questions:
Are there better methods to combine Nh.Burrow with WCF?...
Lets say you are working in SQL 2005 with a copy of Northwind database installed.
Your working on an ASP.NET application with an Employees "browse" page.
At the top of the page you have a "Title" filter where you would like to display these 5 choices in a dropdown:
[ALL]
Vice President, Sales
Sales Representative
Sales Manager
...
I have a following domain model:
Entity1 -> ValueType1-> Entity2
How can I write the mapping file to represent the above situation (while retrieving Entity1)?
PS: I know I can use component tag when value type does not refer to another entity (in this case Entity2).
Thanks
...
Hi I'm working a project where we need to process several xml files once a day and populate a Database with the information contained in those files.
Each file is roughly 1Mb and contains about 1000 records; we usually need to process between 12 and 25 of these files. I've seen some information regarding bulk inserts using NHibernate b...
Let's say I've got the following ActiveRecord class:
[ActiveRecord]
public class Account
{
...
[BelongsTo("CustomerId")]
public Customer Customer { get; set; }
}
Currently, to set the value of the CustomerId field I have to get the entire Customer object from the database and assign it to the Account:
Customer customer =...
I have the two following tables (SQL Server):
**IndexValues**
IdIndexValue int (PK)
Value varchar(2000)
IdIndex int (FK for Table Indexes)
IdDocument int (FK for Table Documents)
**IndexValuesLists**
IdIndexValueList int (PK)
IdIndexValue int (PK with IdIndexValueList, FK for Table Indexes)
Explaining a little, the second table grou...
Let's say I have this in an implementation of IInstanceProvider:
public void ReleaseInstance(InstanceContext instanceContext, object instance)
{
try
{
unitOfWork.Commit();
}
catch (Exception)
{
unitOfWork.Rollback();
throw;
}
finally
{
unitOfWork.Dispose();
}
}
That t...
Almost certainly a stupid question but I can't find the answer anywhere.
In the Getting Started tutorial the database is SQLite and so his session factory creation
is done using the SQLiteConfiguration class in the FluentNHibernate.Cfg.Db namespace
Great! But I don't see a Configuration class for using an Oracle database. How do I do...
Where can I find a good NHibernate and ASP.NET MVC Reference Application? I downloaded S#arp and this seemed to be a lot more than I needed (IOC and CodeGen via T4). I might work my way up to this later, but I need something smaller at first.
Any simple examples? I just want to pick up how NHibernate Session handling works in ASP.NET MV...
I have a hierarchy of objects, Order, Contact, Address:
public class Order {
public virtual Contact BillingContact { get; set; }
}
public class Contact {
public virtual Address Address { get; set; }
}
I want to query an order by id, and eager load the billingcontact, along with it's address.
var criteria = DetachedCriteria...
I think I have tried every thing to get this to work but to no avail.
Any hints/help much appreciated.
The following parent-children relationship causes the following error on creation of the parent.
could not insert: [Kanpeki.Domain.CalEvtCatergory][SQL: INSERT INTO tb_calEvent_catergory (catergoryID, parentID, catergoryType, catergor...
I have a class
public class Site {
public DateTime SiteMonth {get; set;}
}
in the database the SiteMonth is represented as an integer in yyyymm format.
Is there a way to map this in NHibernate without introducing a new property on my Site class?
...
Hey,
I have a pretty simple NHibernate setup: an Item object which has a collection of ItemDetail objects. One-to-many relationship between them.
In my web application, I'm writing code similar to:
item.Details.Add(new ItemDetail { Item = item, Text = "blah" });
itemRepos.Save(item);
This all works well. However, now I'm writing a s...