I've got a MS-SQL database with a table created with this code
CREATE TABLE [dbo].[portfoliomanager](
[idPortfolioManager] [int] NOT NULL PRIMARY KEY IDENTITY,
[name] [varchar](45) NULL
)
so that idPortfolioManager is my primary key and also auto-incrementing. Now on my Windows WPF application I'm using NHibernate to help with adding...
Last night I started working on an NHibernate provider. I'm creating a criteria that several records will match, however I only want to return the most recent record (the record with the largest Id). I thought UniqueResult() would do this it cannot be used if a list would be returned otherwise.
I could theoretically select the full li...
My problem is that NHibernate gets exponentially slow when fetching records from the database. I had a request to basically pull all the data from a very large database to be used in a report.
I figured, well since I can't get all the records in one shot because the recordset is so large, i thought try breaking it up. Basically I'm ite...
How should I have the NHibernate Session Factory and the sessions for a WinForms application?
Should the SessionFactory be a singleton? Or can I create it every time? What about sessions and transactions?
Any help would be appreciated. Thanks
...
Hello,
I am creating a simple project management system which uses NHibernate for object storage. The underlying database is SQL express (at least currently for development).
The client runs on either the desktop or laptop. I know I could use web-services and store the DB only on the desktop, but this would force the desktop to be avai...
I have entity A which has an IList of B called Bs and B has an IList of C called Cs.
I want to search for all A's which have at least 5 C's in them. So I went and wrote
using (var s = this._sessionFactory.OpenSession())
{
IQueryable<A> q = s.Linq<A>();
// some code...
if (range.Min.HasValue)
q = ...
Dear All!
I try to set-up a clean and flexbible application-framework for data-centric applications with silverlight-only UI. I want to have a strict seperation of concerns, and want to be as flexible as possible (e.g. exchange the ORM later) while still reducing the amount of code.
It took me weeks to figure out an appropriate archite...
I have an entity type A. Which has many B's. The B entity has many C's.
I need to count how many C's does an A entity have. How can this be done using NHibernate Criteria API?
Using LINQ to NHibernate I was unable to get results since it throws an exception (see this question)
...
Hi,
i want to map two classes m:n associated using NHibernate. NH would map a simple m:n association in a link table with foreign key constraints to the entity tables. Now I want to attach more attributes to the association as seen on this example:
(and I want NHibernate to store these attributes in the link table)
This UML diagram s...
I hear a lot about performance problems about lazy loading, no matter if at NHibernate, Linq....
The problem is N+1 selects. Example, I want all posts and its users, at foreach I lazy Load Users, them I need one select for posts, plus N select for each user.
Lazy Loading:
1 - select ....from post
N - select ....from user
The "good" ap...
Assume the following entity classes:
public class Player
{
public virtual int ID { get; set; }
public virtual string Name { get; set; }
public virtual Team Team { get; set; }
}
public class Team
{
public virtual int ID { get; set; }
public virtual string City { get; set; }
public virtual string Nickname { get; set; }
}
Assume t...
[pre-able]
In my www.twipler.com project I want to allow people to link Twitter accounts. This will be achieved by having them login, selecting "link account" and then logging in again. This will effectively give me UserId-1 and UserId-2. Now I want to allow the user to login with either UserId-1 or UserId-2 credentials and then retreive...
I am trying to use LINQ to Nhibernate to get a count on a table in my database. However, the code I am running is pulling back all of the records in the table versus running select count() from table.
Here's my code-
public int GetTotalCount(Func<T, bool> where) {
IQueryable<T> queryable = this._sessionManager.GetCurrentS...
I'm trying to use NHibernate to map a table per subclass inheritance structure that looks something like this:
public class BaseClass
{
public virtual IColllection<BaseClassCollection> Collection { get; set; }
}
public class ChildClass : BaseClass
{
public new virtual ICollection<ChildClassCollection> Collection { get; set; }
}...
While trying to create a Bi-directional one-to-one mapping in NHibernate, I found that, I am unable to have the Reference of the objects recursively.
For example: suppose I have one-to-one relationships between Person and Address.
then after executing the following code,
class Person
{
... ...
public Address Address { get;set;...
Here are my classes:
public abstract class TypeBase
{
public virtual int? Id { get; set; }
public virtual string Name { get; set; }
}
// various other classes extend TypeBase the same way
public class Color : TypeBase
{
}
public class Template
{
public virtual int? Id { get; set; }
public virtual IList<Style...
I have a problem with the DefaultUpdateEventListener in NHibernate.
I will update 2 objects and then i commit the session.
The first object didn't come into the listener and the second object comes there.
So i checked with reflector to check what the problem is
First NHibernate will call the PerformSaveOrUpdate in the DefeultSaveOrUpd...
Hello
I have a working one to many relationship (NOT bbidirectional) where Resource has a set of many Allocations implented as shown below. The domain needs to do more with the collection of allocations that just manage it with AddAllocation, RemoveAllocation, etc. So from an object perspective, I'd like to put that extra logic that is ...
Note, this is some ancient NHibernate installation! I have the following NHibernate class:
[Serializable]
[Class(Table = "SomeEvents")]
public class SomeEvent
{
[Property(Column="processDate")]
public DateTime? ProcessDate { get; set; }
}
When trying to update some events like:
using (ISession session = FDK_Hibernate_Manager....
This question was asked back in October (unable-to-cast-object-of-type-nhibernate-collection-generic-persistentgenericbag). Basically, I have a POCO that has a one-to-many relationship modeled by a List<ChildType>. When you try to get it/save it in NHibernate you get a type cast exception saying it's trying to cast from NHibernate.Colle...