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 ...
hi
i have written a code like this
public class person
{
public person()
{
public virtual int Id { get; set; }
public virtual string Code { get; set; }
}
}
public class Child : Person
{
public person()
{
...
Hello,
I am using Fluent NHibernate in my application.
I have a criteria query that looks like this -
var query = DetachedCriteria
.For<table2>()
.SetProjection(Projections.Distinct(Projections.Property("id")))
//.Add(Restrictions.Between("date_field", startDate, endDate))
...
How to map a class that has another class nested inside it. I am using automapping. It gives exception 'NHibernate.MappingException: Association references unmapped class: class1+class2'
suppose you have
public class baseclass
{
}
public class class1 : baseclass
{
public class class2 : baseclass
{
}
}
...
I'm having some trouble figuring out the correct syntax for mapping a many-to-many relationship with FluentNHibernate. I've looked at several of the other questions here on SO and other places, but haven't seen anything with, specifically, the same table structure. Hoping someone that knows more than I do about FNH can help me figure thi...
I have a product object that contains 2 collections, accessories and consumers. Consumers relates to an accessory, the list of products that consume it. In the database I have a many to many relationship for these collections that is implemented as a linking table Product_Accessory. In mapping I have created a many to many one way for th...
I have an entity with a surrogate Id and a composite NaturalId mapped with FluentNHibernate. I make the natural id mutable marking it "Not.ReadOnly()". Something like:
public class EntityMap: ClassMap<Entity>
{
public EntityMap()
{
Id(x => x.Id);
NaturalId().Not.ReadOnly()
...
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...
Is it possible to set a naming convention for all collection of an entity even if I use the Access Strategy or not, so that all collection names are {EnityName}s instead of {entityName}s (because of Access.CamelCaseField(Prefix.Underscore) the first letter is lower)?
Or is there a way where I can tell NHibernate that it shall use the as...
I'm trying to follow this page http://jagregory.com/writings/fluent-nhibernate-conventions-rewrite/ to define conventions for Fluent NHibernate.
I'm using 1.1.0.685, and when I use this code:
public class TableNameConvention : IClassConvention
{
public bool Accept(IClassMap classMap)
{
return true; // apply to all mappings
}
...
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...
I have a class structure as follows (pseudo code):
CompanyName (id, name) // Other information about the company
IUsefulSearchField // A field that can appear at any depth in the below
IUsefulSearchField2 // A field that can appear at any depth in the below
BaseClass (id) // Some other values needed in class & This class will be inh...
I am a bit new to Fluent nHibernate and ran into a scenario with my schema I'm not sure how to address.
Say I have two tables:
Track
TrackId
UserId
Name
Users
UserId
Name
Now, what I want to do is have the ability to access the related User object by track. For example:
var track = repo.GetById(1);
var userName = track.User.Name...
Hi,
I'm auditing certain values using a NHibernate Audit Inteceptor - I have inherited from the EmptyInteceptor and overridden the OnFlushDirty
public override bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types)
{
For the most part the currentState and ...
Hello,
I'm struggling with something fairly basic. I have a one-to-many relationship and I'm setting the fetchmode to inner join in my Criteria query. I see the resulting SQL includes the join, but it also lazily fetches the child entities. What am I doing wrong?
Mappings (Industry has many Manufacturers):
public class IndustryMap :...
Starting with some code:
sessionFactory = Fluently.Configure(cfg)
.Mappings(m =>
{
List<Assembly> allAssemblies = new List<Assembly>();
string path = Assembly.GetExecutingAssembly().Location;
foreach (string dll in Directory.GetFiles(path, "*.dl...
is any way to optimize this solution?
whether there is any possibility of obtaining the same result by calling single query?
public List<Company> GetCompanies(DateTime maxDate, int stockQuotesCount)
{
List<Company> result = new List<Company>();
IList<Company> company = null;
DateTime lastSessionDate = new St...
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...
I'm fairly new to Fluent NHibernate and am trying to use inheritance but I'm getting unexpected results in the database schema created by NHibernate. Hopefully someone can shed some light or point out what I'm doing wrong this this example:
public class BaseClassMap: ClassMap<BaseClass>
{
BaseClassMap()
{
Id(x => x.Id).GeneratedBy....
Hello all,
I have two tables
tblPart
(
partId,
subpartId UNIQUE NULL
)
tblSubpart
(
subpartId
)
So I can only have zero or one subPart associated with the part at the same time.
I'm trying to map this as
ClassMap<Part>
{
HasOne(x=>x.Subpart);
}
and the convention rewrites the foreign key so it uses subpartId ins...