For example, if you have an Apple : IWhatever, and an Orange : IWhatever and you want to find both of them because they are IWhatevers, what do you need to do in NHibernate?
Is it completely dependent on the HQL or criteria query, or is there something you must do in the mapping also? If there is a mapping requirement, can Fluent NHiber...
I have a collection mapped as a query only property following Ayende's example. My mapping is:
HasMany<Employee>(Reveal.Member<Company>("_employees")).Access.None();
This worked fine, except when I load a Company the foreign key Employee.CompanyId is updated to null. This occurs even if I don't update Company and the generated SQL onl...
When you create a criteria, you can add Restrictions that apply to a property. There are 2 ways of creating a Restriction:
Restrictions.Eq(string propertyName, object value)
or
Restrictions.Eq(IProjection projection, object value)
Thing is, I don't feel comfortable passing property names as strings, since if they ever change, my projec...
I am trying to migrate a V1.2 app to V2.1.2. Previously I could save my HQL queries in embedded XML files then load them like this:
configuration.AddXmlString(ReadMyFileFromResourceUsingReflection("MyQueries.xml"));
where ReadMyFile... is a function that gets the embedded XML from the assembly etc etc.
This worked fine before. In V...
I'm a bit out of my depth in a project I've been recently dropped into. Can somebody please recommend a book that might help me float? (whereby 'float', I mean 'learn NHibernate' :-)).
Thanks
...
Hi,
I am new to Nhibernate. I want to retrieve collection of records against an entity. For example to retrieve a single record I have used the following statement:
resultObject=session.Get(id);
This above statement would retrieve a single record based on the
'id" I provide.
But I want to retrieve multiple rows from a table the way w...
I am using the Specification pattern, and have a working implementation (taken from the WhoCanHelpMe Codeplex project) for getting data via NLinq, generic repositories and all that goodness.
The root method is:
public IList<Case> GetCasesByUsername(string username)
{
CaseByUserNameSpecification spc = new CaseByUserNameSpecification...
I'm trying to get Fluent and NHibernate configured properly with ASP.NET MVC. As far as I know it's configured properly but when I access the page that uses this setup I am not receiving any data results.
The model I'm using is called Brand and the database table is Brands.
Here is a snippet from my BrandController:
public ActionResul...
Let's say you have three entities - Categories, Sites and Items. The Items table has a CategoryID and a SiteID. If I want to find the sites for a given category, I can get that with a mapping in NHibernate that looks something like:
public CategoryMap()
{
//..
ManyToMany(x => x.Site)
.Table("Items")
.ParentKey("CategoryID")
...
Hi all,
When having the following model:
class Organisation {
}
class Insurance : Organisation {
public int UZOVInumber {get;set;)
...
}
class HealthcareOffice : Organisation {
public int UZOVInumber {get;set;)
...
}
class OtherOrganisation : Organisation {
...
}
You can see that 2 subclasses have the same prop...
hi, i have readonly VIEWs in an existing Database and i'd like to get them with FHN. i tried mapping it the following way:
public class HhstMap : ClassMap<Hhst>
{
public HhstMap()
{
Table("HHST");
ReadOnly();
Id();
Map(x => x.Hkz);
Map(x => x.Kapitel);
Map(x => x.Titel);
...
I am trying to perform a LEFT OUTER JOIN with nhibernate criteria. I also have a filter that gets applied to my queries.
The problem I have is the filter stops the left outer join working properly if the join result is null.
As a very simple example I want to return all the musicians, and if they are in a band then also their band
NHi...
I currently have code which produces the following LINQ expression (taken from the WhoCanHelpMe showcase project). Its purpose is to bind together two expressions but I don't know if the following is actually a valid expression:
.Where(p => (p.PostCodes
.Any(pc =>(pc = value(PatchByPostCodeSpecification).postCode)) &&
In...
What is the new SetAttribute() in FNH mapping? I need to set my discriminator value on subclass because String is not preferred - old post
with NH 2.1.2.4000, FNH 1.1.0.689
public class BaseBuildingMap : ClassMap<BaseBuilding>
{
public BaseBuildingMap()
{
Id(x => x.Id);
DiscriminateSubClassesOnColumn<int>("Build...
I'm trying to convince my client to use nhibernate instead of Entity Framework 4. My client have decided to use only Microsoft libraries (including Unity and Enterprise library 5). I don't agree with them (there are so much better logging frameworks/validation layers/ioc etc) but respect their decision.
I've played with EF4 for a couple...
Imagine the following tables :
Tag (TagId, Label)
Post (PostId, Title, Content)
User (UserId, Name)
UserPostTag (Id, UserId, PostId, TagId)
For a Post, multiple users can add one or more Tag.
I want to get, via nHibernate, the tag list for a post, with the count of each Tag.
Exemple or result :
Tag(id1, label1), 7...
I need to call a stored procedure through nhibernate. But I did not know it make.
I have simple stored procedure:
CREATE PROCEDURE InsertDoc
@Name nvarchar(50),
@Author nvarchar(50),
@Link nvarchar(50)
AS
INSERT INTO documents(name, date, author, doclink)
VALUES(@Name, CURRENT_TIMESTAMP, @Author, @Link)
I do th...
In the company I work for, we're using a NHibernate session wrapper that disposes all the sessions opened in the current web request at the end of the same request, and commits all the associated transactions (we're working in a multi-database environment, and we create a session for every database).
Also, in the session wrapper we're u...
Here's the scenario:
I have 3 objects called Person, VideoGame, and Store.
One Person can have many VideoGames
One VideoGame can belong to many Persons
Same M:N relationship is between Store and VideoGames
In the DB, the only thing besides these entities are two simple join tables PersonsVideoGames and StoresVideoGames.
Assume ever...
In a web application, I want to cache heavy calls into the db.
So I want to do ansyc reads, store the result from read and transformation in a store and present the newest data I have available at the time of the request (sometimes stale)
// that is the entry point
public virtual IViewData DetailByKey(string key)
{
var articleDetail...