I have Product and Category tables in database.
One product can have many categories.
One category can have many products.
So, I have a third table as ProductCategory, which has ProductID and CategoryID.
In Fluent NHibernate, what does the mapping class should look like?
For example, For ProductMap class is it correct:
HasMany(x =>...
Hi all
I have a data access class with an Enum called Salutation:
public enum Salutation
{
Unknown = 0,
Dame = 1,
etc
Mr = 5,
etc
}
I am peristing the class with NHibernate, and up until this morning I was using .hbm.xml files for mapping. However, I've now switched to using Fluent NHibernate, but loading ins...
Hi all
I love the feature in NHibernate that shows the generated SQL. But when I pasted it into SQL Server Management Studio, I realised it's not actually valid!
Here's an example:
SELECT person0_.PersonId as PersonId1_0_, person0_.Title as Title1_0_, person0_.FirstName as FirstName1_0_, person0_.MiddleNames as MiddleNa4_1_0_, person0...
Hi,
I'm trying to create a query using linq 2 nhibernate which generate a sql like:
select * from table
where id in (1, 2, 3, 4)
At the moment I have this code:
var vouchers = Session.Linq<Voucher>()
.Where(x => campaignIds.Contains(x.VoucherGroup.Campaign.Id))
.ToA...
I am using castle active record, I load an enity using the .Find() method, after updating the database i call entity.Refresh() but the entity doesn't refresh, the data that i changed in the database is not reflected in the state of the entity. I am at a total loss as to how to get this to work.
...
I have a list of orders, which are connected to a user-table. Each order can contain multiple users.
I then have a search area where an admin can search through all orders by searching for e.g. a last name.
If there is done a search for e.g. Smith, all orders where a user named smith should be shown, but how is this done with NHiberna...
I have a list of orders, which are connected to a user-table. Each order can contain multiple users.
I then have a search area where an admin can search through all orders by searching for e.g. a last name.
If there is done a search for e.g. Smith, all orders where a user named smith should be shown, but how is this done with NHiberna...
Hello, gentlemen! First, I've tried to ask the similar question yesterday (http://stackoverflow.com/questions/3255407/nhibernate-many-to-many-relationship-question-can-select-cant-update), but after a debugging night hopefully I can rephrase a question the better (right?) way. If I am doing something wrong by that - please tell - I'll er...
[Edit: forget this post - I'm not sure what NHibernate is doing, but it's not doing what I just said it's doing. Please ignore.]
I have a 'parent' class in the object graph called Case.
Here's a snapshot of Case:
public class Case
{
public virtual Person Deceased {get;set;}
public virtual IList Executors { get; set; }
public Ca...
Hopefully I can express this in a coherent and meaningful way:
Two of our DBA's came up to me today after an email I sent explaining why we were using NHibernate and the benefits of an ORM framework. They have been pushing hard for refactoring our stored procs to include instrumentation like this:
BEGIN
DBMS_APPLICATION_INFO.set_module...
I have a simple object model of a header with multiple detail lines. I have mapped a bag property on the header object to the line class and also put a header property on the line class to set the two way relationship.
When I run my tests, using NHibernate Profiler I can see that the query is being performed, and the header and lines ar...
I have a custom event listener being added (fluently) to my configuration using:
.ExposeConfiguration(c => c.SetListener(ListenerType.SaveUpdate, listener))
My listener just captures before a save or update and handles audit fields (CreatedBy, Modified By, etc.)
protected override object PerformSaveOrUpdate(SaveOrUpdateEvent sender)
...
Hi all
Let's say you have two classes, Person and Address.
Person has a reference to Address like this:
public class Person
{
public virtual Address Residence {get;set;}
}
Address has an override of .Equals which determines whether two Address instances represent the same physical address (by comparing postcode and first line, say...
I have this nhibernate query:
var q =
NHibernateSession.Current.CreateSQLQuery
(
@"SELECT LastestEvents.*
FROM (
SELECT DISTINCT SbQcontainer.Container
FROM HistoricEvents
SbQc...
I first try and pull the customer from the db, but if my customer doesn't exist, then i make a sql call another db on the server to get the information. I'd like to then save the customer info in my db. The Session is currently hooked up to my db.
var customer = Session.Linq<Customer>().FirstOrDefault(x=>x.customernumber == cusotmerNu...
I have a Case class which exposes a Person object as follows:
public class Case
{
public virtual Person Deceased {get;set;}
}
I have a PersonalAsset class which also exposes a Person:
public class PersonalAsset
{
public virtual Person Owner {get;set;}
}
Assuming I write the following code within an ISession:
Case case = new Ca...
I have used SQL Server 2008 configured in hibernate.cfg.xml file and everything worked fine. Once I tried to use SQLite in memory.. I have having the following issues...
hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory>
...
Hello all,
The entities and mappings I'm talking about in this question can be found here :)
Here is the context:
I have a parent view-model which helps to manage some entities, and which has its own session.
From this VM, I open another view-model (with its own session too), do some changements to the entity (add and/or remove child...
public class Case
{
public int Id { get; set; }
public string Number { get; set; }
public Employee Employee { get; set; }
}
public class Employee
{
public int Id { get; set; }
public string EmployerIdentifier { get; set; }
public Case Case { get; set; }
}
There is a one to one releationship between Case and Emp...
I have an entity with a CompositeId that won't insert new rows to the database using SaveOrUpdateCopy. The INSERT statement generated by NHibernate is populated with "?" for the value of every field. It inserts fine with SaveOrUpdate, it updates fine with either SaveOrUpdateCopy or SaveOrUpdate, and any entity without a CompositeId ins...