using System.Collections.Generic;
using DataLoader.Domain;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTest
{
/// <summary>
/// Unit test that reloads the database schema based on Hibernate mapping files.
/// </summary>
[TestClass]
public clas...
If I forgot to add mappings to a persister object, NHibernate will throw an exception when I'll run the application.
I want to write an integration tests, that test that all mappings are provided to NHibernate. what is the way you recommend to follow?
...
Very close to what I'm trying to do but not quite the answer I think I'm looking for:
How to map IDictionary<string, Entity> in Fluent NHibernate
I'm trying to implement an IDictionary<String, IList<MyEntity>>and map this collection to the database using NHibernate. I do understand that you cannot map collections of collections directl...
I have a c# library project, that i configured using nhibernate, and I like people to be able to import this project and use the project. This project has FrontController that does all the work.
I have a connection string in hibernate config file and in app.config file of another project.
it would be nice for anyone to be able to set t...
At the moment, we've got an unmaintanable ball of code which offers an interface to a third party application. The third party application has a COM assembly which MUST be used to create new entries. This process involves two steps: generate a new object (basically an ID), and update that object with new field values.
Because COM interop...
Hi there
I have a class.
public class MedicalRequest
{
private int id
private IList<MedicalDays> Days
private string MedicalUser
...
}
and another
public class MedicalDays
{
private int id;
private DateTime? day
private MedicalRequest request
...
}
I'm using nhibernate to return a list of all t...
Hi, I'm trying to implement Membership controls in a mvc 2 application and i'm having trouble dealing with the MembershipUser class.
I have my own data store (in Postgresql) and I'm using Nhibernate to deal with it from C#. The thing is, I have my own user class, but I can't use it with any provider I found that implements Membership, ...
What is the best way to design the Domain objects which can have multi-lingual fields. An example can be a Product class with Description being multi-lingual.
I have found few links but could not decide which one is the best way.
http://fabiomaulo.blogspot.com/2009/06/localized-property-with-nhibernate.html
(This stores all localised ...
I have a bag defined for a many-to-many list:
<class name="Author" table="Authors">
<id name="Id" column="AuthorId">
<generator class="identity" />
</id>
<property name="Name" />
<bag name="Books" table="Author_Book_Map" where="IsDeleted=0" fetch="join">
<key column="AuthorId" />
<many-to...
Hi all, i'd like to know, I have a application in asp.net mvc and nhibernate. I've read about that in the Views on asp.net mvc, shouldn't know about the Domain, and it need use a DTO object. So, I'm trying to do this, I found the AutoMapper component and I don't know the correct way to do my DTOS, for some domain objects. I have a domain...
Hi there!
In my project I am using NHibernate/FluentNHibernate, and I am working with two entities, contracts and services.
This is my contract type:
[Serializable]
public partial class TTLCContract
{
public virtual long? Id { get; set; }
// other properties here
public virtual Iesi.Collections.Generic.ISet<TTLCService> Se...
Hi,
I am new to NHibernate and need some information regarding the internal working of the engine:
I have a table called Student and the design is as follows:
RollNo
Name
City
Postcode
and there are 5 more columns like this. I have School class and mappings associated with it.
I am querying RollNo and Name using session as given be...
I am starting to play with (Fluent) nHibernate and I am wondering if someone can help with the following. I'm sure it's a total noob question.
I want to do:
delete from TABX where name = 'abc'
where table TABX is defined as:
ID int
name varchar(32)
...
I build the code based on internet samples:
using (ITransaction t...
I'm developing an app with a Silverlight UI, transferring my domain objects over WCF and persisting them via NHibernate.
I'm therefore working with NHibernate in a disconnected mode.
I'm already using the NHibernate PreUpdate and PreInsert EventListeners to perform some metadata operations (updating Create/Update date, created/updated b...
Hi I want to fetch the data form data base using hibernate Criteria API.
That data should be ordered by some column as number.
This column is defined as varchar in DB. But I have to fetch as numberic.
I am facing problem using criteria API as it is ordering like string onyly.
Ex:
I am getting data like
9, 8, 7, 6, 5, 4, 3, 2, 1,10
...
I have a few classes that read from very delicate tables, which is why I want them to be used by NHibernate as "ReadOnly". Establishing .ReadOnly() on each field map is really sloppy, and I'm not sure I trust it. How do I setup a class to be entirely readonly, as I can easily do with traditional XML mappings?
Edit: The answer does work....
I have an nHibernate query using Criteria, and I am trying to cast a string to bool in the query itself. I have done the same with casting a string to int, and that works well (the "DataField" property is "1" as a string):
var result = Session
.CreateCriteria<Car>()
.Add(Restrictions.Eq((Projections.Cast(NHibernateUtil.Int32,
...
I have a table in my database that represents datafields in a custom form. The DataField gives some representation of what kind of control it should be represented with, and what value type it should take. Simplified you can say that I have 2 entities in this table - Textbox taking any string and Textbox only taking numbers.
Now I have...
I use a stateless session and the follow HQL.
CreateQuery("select a from Address a")
My Address Class has many BankDetails but i can't access. If i use a normal session it works. What can I do?
...
How do I instruct Nhibernate to generate sequential one step primary keys, like the sql generated ones?
The current HiLo algorithm generates keys like 4001 then 5010, 6089 etc. I understand that this is to manage multiple app servers etc. But I don’t have that problem.
I need nhibernate to pick up the highest record set value during...