Hello,
according to this Post it is possible to change the naming convention from "[TableName]_id" to "[TableName]ID". However when I saw the code, I wasn't able to do it with my rather new (about 6 weeks old) version of Fluent NHibernate.
Original code:
var cfg = new Configuration().Configure();
var persistenceModel = new Persistence...
On my site, people can buy parts for vehicles. I want to create a report for a customer to see how much they have spent on parts per month on the site, and allow them to filter by date. If I was writing it in SQL, I would write this:
SELECT
v.id,
DATEPART(YEAR, o.order_date),
DATEPART(MONTH, o.order_date),
SUM(i.unit_...
I need to get the products in the system that match certain criteria.
How should i decide if I should write an HQL and get all products that match the criteria from DB or write a Linq query directly to the main List that contain all products in the system.
Which should be better performance vise
...
I have an object from my domain model that has a child object. How can I use a criteria query to order based on a property of the child?
For example:
class FooType
{
public int Id { get; set; }
public string Name { get; set; }
public BarType Bar { get; set; }
}
class BarType
{
public int Id { get; set; }
public st...
How can I find/set the Assembly Name for Web Site created in Visual Web Developer?
Actually I am trying out NHibernate with Visual Web Developer Web site. In the .hbm.xml (mapping file) contains a attribute called Assembly where we need to specify the Assembly Name of the Project containing the entity class.
Where can I find the assemb...
Hi,
Is it possible to set the default value of a property in NHibernate? Here is the scenario:
I have a self join table Category. The class and table structure are as follows:
Category
int Id
string Name
Category ParentCategory
Category
int Id not null
varchar Name not null
int ParentCategoryId not null
If a category has no parent,...
UPDATED: This is totally wrong assumption. I retested it and sure enough I was mistaken. NHibernate generates SQL that will get all children rows to both Children Lists. Thank sirrocco for the comment. I think the better question is how we could do something like this work.
I modified the code a bit from Fluent NHibernate Examples in Wi...
Say my requirement is
"search for all users by name, who are over 18"
If i were using SQL, i might write something like:
Select * from [Users]
Where ([firstname] like '%' + @searchTerm + '%' OR
[lastname] like '%' + @searchTerm + '%')
AND [age] >= 18
However, im having difficulty translating this into lucene.net.
This ...
Hi !
Considering the following mapping file where TemporaryAccessOpenCommand and TemporaryAccessCloseCommand both inherit from base class Command
<class name="Command" table="xxx_Commands" lazy="false">
<id name="Id" type="Int32" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="BeginDate" />
<property name="EndD...
Has anyone come across a tool to visualize an ActiveRecord / NHibernate entity model?
...
NOTE: I posted this on sharp architecture google groups also.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: SharpArch.Core.PreconditionException: A session
factory ha...
I decided to implement the event listeners in the latest build of NHibernate to keep track of who is making edits and what those edits are. My question is this - the below does work and I can step through it but what I'm not sure how these changes get saved ... do I need to build an audit table and write a mapping for it to call a save ...
I have the following structure:
[Class]
public class SuperClass
{
}
[JoinedSubclass]
public class SubClass : SuperClass
{
}
[Class]
public class ContainerClass
{
[ManyToOne]
public SuperClass SomeProperty {get; set;}
}
However, when retrieving an instance of ContainerClass via Hibernate.ISession.Get, it always returns me an ...
I am designing an OO object model with a plan to use NHibernate as the data access layer.
I'd like to know the best OO design when dealing with two entities that have a many to many relationship with each other (especially for easy integration with NHibernate).
The objects:
User - a single User can be related to multiple Subjects
Subje...
When using NHibernate, you define your entites with virtual methods, and NHibernate will create a proxy object that tracks changes to your object.
In Moq, the framework will magically create a derived type from an interface or a base class. e.g.
var mock = new Mock<IFoo>();
IFoo magicFoo = mock.Object;
This is really cool. How do...
How can I create a disjunction in NHibernate that would accomplish the following sql:
Select * from MyTable
Where (conditionA = true AND conditionB = true)
OR (conditionC = true AND conditionD = true)
From what I've seen, the Disjuntion() takes single criterions and "ORs" them together. Is it possible to group to criterion tog...
Hello,
I have a User with related Permissions. Here is what I want:
I create a User and add a permission to the User.Permissions collection. It gets saved and everything happens as expected.
Then I edit the user and remove the permission. A new user object is then created and the permissions collection is empty. The identifier and...
I have a class hierarchy mapped into one table. There is one superclass and 8 different sub classes. A lot of my queries needs to fetch e.g. 2 of the sub classes only for a specific date.
The table has a discriminator column that nhibernate itself uses. But when using LINQ for querying it is not possible to use this discriminator as ther...
Is it possible to navigate through the key-many-to-one associations of a composite-id in Nhibernate?
I have a few (legacy) tables that I mapped with the following settings:
<class name="StructureUser">
<composite-id>
<key-many-to-one name="Structure" class="Structure" column="STRUKTUR_ID" />
<key-many-to-one name="U...
Hi
They say that to build a session factory in NHibernate is expensive and that it should only happen once. I use a singleton approach on this. This is done on the first time that a session is requested.
My question : Would there every be a time when you should close the Session factory? If so, when would one do this?
...