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...
I have two tables, Locations and Facilities
They map to two classes,
public Location : Entity
{
//properties
}
public Facility : Entity
{
public virtual Location Location { get; set; }
}
Everything works just dandy, until I change facility to this
public Facility : Location
{
}
Now I get an exception from nHibernate sayi...
Hi,
I'm automapping most of my model, but have a problem with generics.
I've got ValueContainer, and I make it abstract so that it
doesn't throw an exception during automapping. Next, I have to create
classes like StringValueContainer just to make it mapped. Needless to
say, I don't like this approach, since I'm perfectly happy with the...
I thought I understood what I was doing, and I swear this used to work when I used it in my last project!
I have an abstract class Enity that I use as a base class for all my DomainModel classes when working with NHibernate. The class is defined as:
public abstract class Entity<TKey> where TKey : IComparable
{
public abstract TK...
I have a class called Worker
public class Worker : BaseEntity
{
public virtual int WorkerID { get; set; }
public virtual string Name { get; set; }
public virtual IList<Indemnification> Indemnifications { get; set; }
}
public class Indemnification : BaseEntity
{
public virtual int IndemnificationID { get; set; }
pu...
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 have a TrackLog that contains a collection of GPS points as a TrackPoint object:
public class TrackPoint
{
public virtual int Id { get; set; }
public virtual List<TrackPoint> TrackPoints { get;set; }
}
public class TrackLog
{
public virtual double Latitude { get; set; }
public virtual double Longitude { get; set; }
...
in NHibernate, i invoke delete but update is invoked automatically!!
i use FluentNhibernate Automapping.
...
I'm getting a SQL query from NH, and it's generating a column that does not exist (thus producing an ADOException from NH).
SELECT roles0_.CreatedBy_id as CreatedBy4_1_,
roles0_.Id as Id1_,
roles0_.Id as Id18_0_,
roles0_.RoleDescription as RoleDesc2_18_0_,
roles0_.User_id as User3_18_0_
FROM [Role] roles...
When i delete some object (or remove it) from a collection (such as list) and call SaveOrUpdate from the parent of this collection the row of the child isn't removed but updated by setting the foreign key value to NULL.
How can i force it to be deleted (the child row).
...
i have the following class:
public class Worker
{
public int WorkerID {get;set;}
public string Name { get;set;}
}
public class TransferOrder
{
public int TransferOrderID { get;set;}
public Worker workerTobeTransfered{get;set;}
}
how do i automap this classes in fluent nhibernate.
...
i'm using oracle with FluentNHibernate automapping with alterations & NHibernate
the problem is how to specify the constraint name by overriding the mapping model??
the generated sql like this:
alter table FirstTable
add constraint FK_VerLongIdentifierLongerThan30Characther
foreign key (FirstTableID)
references SecondTable...
I'm considering to use AutoMapper in the upcoming project and trying to find possible "bottlenecks". At the moment the most complex case i can imagine is the following:
A domain class which is represented by 3 (for example) tables in the database (my data access layer is LINQ to SQL). To build an instance of the class i need to perform 3...
When using auto mappings in Fluent NHibernate, you have the ability to do something like:
_configuration =
Fluently.Configure().
Database(
MsSqlConfiguration.MsSql2000.ConnectionString(
@"some connection string")
)
.Mappings(
m => m.AutoMappings.Add(AutoMap.Assembly...