using fluent nhibernate, and automappings (nhibernate creates my db schema), how can i get nhibernate to create a nvarchar(max) column in the database based on the following class
public class VirtualPage : BaseEntity
{
public virtual int ParentId { get; set; }
public virtual string PageName { get; set; }
public virtual stri...
I am attempting a subclass mapping in Fluent NHibernate.
In the parent class mapping, I have to specify the ID column name to prevent FNH guessing incorrectly:
Id(x => x.Id).Column("UserId");
I also need to specify the ID (or foreign key if you like) field name in the subclass mapping, since FNH is guessing that incorrectly too. How ...
Out of interest of learning what's going on behind the scenes, I am running some test methods that specifically dump data to my database via NHibernate. I'm toying with various mapping settings and am watching the session processes via the latest version of NHProfiler.
I'm noticing something odd, and it may not be of concern, but thoug...
We have a legacy database that we cannot change. And we are trying to move to the NHibernate instead of old DataAccess layer which is a garbage and is too slow.
it has tables like these:
GPI table has (PU_ID, PAR_ID, Data, Data2) columns
BLOCK table has (GA_ID, Data, PAR_ID) columns
COMPANY table has (PU_ID, Data) columns
I had create...
Hi, I am trying to get this FluentNHibernate mapping to work. I have three tables Person, Employee and Employer. The Employee table extends the attributes of the Person table, and it's primary key is a foreign key to the Person table.
The Employee table also has a foriegn key to the Employer table. An employer can have many employees, a...
I'm looking for a FluentNH (Fluent NHibernate) convention or configuration that ignores all properties that have no setter:
It would still map these:
public class foo{
public virtual int bar {get; private set;}
}
And omit these:
public class foo{
public virtual int fizz{get;private set;}
public virtual int bar{get {return fizz...
So I'm on an NHibernate crash course, and kinda hit a snag with the example below.
Suppose I have the following .NET class:
class A {
int id;
int type_var;
List<B> someCollection;
}
class B {
int id;
string someText;
}
I'll probably map it like :
<class name="A" table="A">
<id name="id" type="Int32">
...
Hi,
I have a SalesOrder table and a separate Address table. The SalesOrder has two addresses - thus avoiding use of a list, there are the Delivery and Invoice address. This is how they have been mapped in the SalesOrder mapping file:
<many-to-one name="DeliveryAddress" class="Address" column="`DeliveryAddressGUID`" />
<many-to-one na...
I am new to NHibernate and am running into some issues with mapping.
Lets say I have a table:
People
PersonID
PersonName
PersonAge
Then I have another table
ParentRelaitions
RelationID
Parent (This is a PersonID)
Child (This is also a PersonID)
What I really want to get out of this is an object like this
public class Person
{
s...
I'm wondering how to best implement a property (here, LatestRequest) which is read-only, backed by a query.
Here, I have an Export, which can be requested to happen multiple times. I'd like to have a property on the Export to get the latest ExportRequest. At the moment, I've got a many-to-one mapping with a formula, like this:
<class ...
I've got a class library doing all my NHibernate stuff. It also handles all the mapping using Fluent NHibernate - no mapping files to deploy.
This class library is consumed by a number of apps, including a Windows Service running on my computer. Although it works fine in all my web apps, the Windows Service gets this when it tries to us...
Suppose I have a table:
ID(pk) | HOME_EMAIL | WORK_EMAIL | OTHER_EMAIL
-------------------------------------------------
and the .NET classes
class A {
int id;
List<MyEmail> emails;
}
class MyEmail {
string email;
}
I suppose there's no way to map those (multiple) columns into a single collection in NHibernate, or is ...
hi, i created the following mappings with fluent nhibernate:
public class AuswahlMap : ClassMap<Auswahl>
{
public AuswahlMap()
{
Table("AUSWAHL");
Id(x => x.Id,"ID")
.GeneratedBy.Sequence("SEQ_AUSWAHL");
Map(x => x.Programm).Not.Nullable();;
Map(x => x.Variante);
Map(x => x...
Hi, i have two entities one called User and another called Membership which has a one to many mapping from User to Membership. I need to add a property on my User entity called CurrentMembership which gets the latest Membership row (ordered by the property DateAdded on the Membership Entity). I'd appreciate it if someone could show me ...
I would like to get correct Exception from ADO.NET about foreign key violation. Is there a way to do that?
I am using try to catch ADO.Exception and check it message text for 'foreign'. So, if there is 'foreign' text in exception text, it is a violation and I can alert.
Is it the right way to do or any other method?
try{
base.De...
Hi, i'm trying to remove an item from a one to many list and have it persist in the database. Here are the entities i have defined:
public class SpecialOffer
{
public virtual int SpecialOfferID { get; set; }
public virtual string Title { get; set; }
public virtual IList<SpecialOfferType> Types { get; private set; }
pub...
Let's start with this mapping:
<component name="Location">
...
<property name="Settings" type="JsonUserType,...">
<column name="LocationSettingsType" />
<column name="LocationSettingsData" />
</property>
</component>
This maps to
TABLE Primary (
...
LocationSettingsType,
LocationSettingsData
...
)
and
...
I have a class that has a many to one property defined as follows:
[NHMA.ManyToOne(Name = "TypeOfEvent", ClassType = typeof(EventType), Column="EventTypeId")]
public virtual EventType TypeOfEvent {get; set;}
Everytime I try to load the class using a simple query (just loading all of the events in the database) I get the following exce...
Good afternoon.
Before I begin my explanation, I have had a look at other similar questions but the subtle differences (mainly in purpose of design) mean that the solutions provided in these answers to not apply to me.
I am attempting to create a 'Base data access library' for use with future projects so that I do not have to spend my ...
Hi,
I'm using NHibernate 2.2 for my database work and I've faced an issue recently. I have a class called PrescDrugItem which is shown below
public class PrescDrugItem
{
public virtual int ItemNumber { get; set; }
[DataMember]
public virtual int AmountIssued { get; set; }
[DataMember]
public virtual string TimePer...