I am experimenting with NHibernate (version 2.1.0.4000) with Fluent NHibernate Automapping.
My test set of entities persists fine with default integer IDs
I am now trying to use Guid IDs with the entities. Unfortunately changing the Id property to a Guid seems to stop NHibernate inserting objects.
Here is the entity class:
public cla...
Hello! I'm using fluentnhibernate with PostgreSQL. Fluentnhibernate is last version. PosrgreSQL version is 8.4.
My code for create ISessionFactory:
public static ISessionFactory CreateSessionFactory()
{
string connectionString = ConfigurationManager.ConnectionStrings["PostgreConnectionString"].ConnectionString;
IPersist...
Kinda stuck here... I have an application with lets say 5000 rows of data per user and was wondering if it was right or wrong to do it this way:
On user account creation a new table is created (UserData_[UserID])
or should I just have 1 table for userdata and have everything in there with a column for userid?
The reason I am stuck at ...
I'm creating a domain model where entities often (but not always) have a member of type ActionLog.
ActionLog is a simple class which allows for an audit trail of actions being performed on an instance. Each action is recorded as an ActionLogEntry instance.
ActionLog is implemented (approximately) as follows:
public class ActionLog
{ ...
I'm getting a the following exception:
"Timeout Expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled conections were in use and max pool size was reached."
...from a relatively heavily trafficked ASP.NET MVC 2 site I developed using StructureMap and Fluent NHiber...
So I have a set up similar to this questions:
Parent Child Setup
Everything works great when saving the parent and the children.
However, I seem to have a problem when selecting the children. I can't seem to get all the children with a specific parent.
This fails with: NHibernate.QueryException: could not resolve property: ParentEnti...
I think I probably know that the most common suggestion will be "change the database schema" but unfortunately it's one of those "I'm stuck with a legacy database" situations.
Basically I want to map the following using Fluent NHibernate
CREATE TABLE Person (PersonId int)
CREATE TABLE Organisation (OrganisationId int)
CREATE TABLE Ow...
Hi,
I've got two tables. Invoice with columns CustomerID, InvoiceDate, Value, InvoiceTypeID (CustomerID and InvoiceDate make up a composite key) and InvoiceType with InvoiceTypeID and InvoiceTypeName columns.
I know I can create my objects like:
public class Invoice
{
public virtual int CustomerID { get; set; }
public virtual ...
I want to map sth like this using fluent Nhibernate but I am not sure how to map the inventory table
This is the tables I have :
Product (Id,Name, ...)
Warehouse(Id, Name, ...)
Inventory(Product_id, Warehouse_id, StockInHand)
I have map the Product and Warehouse like below
Public ProductMap()
{
Id(x => x.Id);
...
I am new to NHibernate and I am having trouble mapping the following relationships within this class.
public class Category : IAuditable
{
public virtual int Id { get; set; }
public virtual string Name{ get; set; }
public virtual Category ParentCategory { get; set; }
public virtual IList<Category> SubCategories { get; se...
Let's say your have the following table structure:
==============================
| Case |
==============================
| Id | int |
| ReferralType | varchar(10) |
+---------| ReferralId | int ...
Hi all
I am struggling a little in getting my mapping right.
What I have is a single self joined table of look up values of certain types. Each lookup can have a parent, which can be of a different type.
For simplicities sake lets take the Country and State example.
So the lookup table would look like this:
Lookups
Id
Key
Valu...
I've been using serialized nhibernate configuration objects (also discussed here and here) to speed up my application startup from about 8s to 1s. I also use fluent-nhibernate, so the path is more like
ClassMap class definitions in code
fluentconfiguration
xml
nhibernate configuration
configuration serialized to disk.
The problem f...
I have a object with a Nhibernate mapping that has a surrogate ID and a natual ID. Since of cource the natural ID is uniquely constrained a insert query will fail if the object is already in the database with the same natural ID. My solution for this has been to manually check to see if natural IDs are in the database before trying to ...
So, I'm having a problem mapping in fluent nhibernate. I want to use a join mapping to flatten an intermediate table: Here's my structure:
[Vehicle]
VehicleId
...
[DTVehicleValueRange]
VehicleId
DTVehicleValueRangeId
AverageValue
...
[DTValueRange]
DTVehicleValueRangeId
RangeMin
RangeMax
RangeValue
Note that DTValueRange does not ha...
I have a join table where the original table is a numeric type and the join table key column is a string type. Legacy decision that I am trying to avoid having to change to minimize the risk to the scope of work.
HasManyToMany<Attachment>(x => x.Attachments)
.Table("ObjectAttachments")
.ParentKeyColumn("ObjectId")
.ChildKeyColumn...
http://www.codinginstinct.com/2010/03/nhibernate-tip-use-set-for-many-to-many.html
I want to do the way the author suggested for fluent nhibernate many-to-many but use automapping instead of HBM file.
Here are my two entities
public class User
{
public virtual int Id { get; set; }
public virtual string Name { get;...
Fluent Mapping
I Have the following scenario
public class CustomerMap : ClassMap
{
public CustomerMap()
{
Table("Customer");
Id(c => c.Id);
Map(c => c.Name);
HasMany(c => c.Orders);
}
}
public class OrderMap : ClassMap<IOrder>
{
public OrderMap()
{
...
I am successfully getting Fluent NHibernate to update my database by calling UpdateBaseFiles:
Public Sub UpdateBaseFiles()
Dim db As SQLiteConfiguration
db = SQLiteConfiguration.Standard.UsingFile(BASE_DBNAME)
Fluently.Configure() _
.Database(db) _
.Mappings(Function(m) m.FluentMappings.AddFromAssemb...
I have two entities, Post and Tag. The Post entity has a collection of Tags which represents a many-to-many join between the two (that is, each post can have any number of tags and each tag can be associated with any number of posts).
I am trying to retrieve all Posts which have a given tag. However, I seem to be unable to get this quer...