I'm developing a website with ASP.NET MVC, NHibernate and Fluent NHibernate and want to know how can I customize my Map to get records using a custom Method.
My entities:
public class ImageGallery {
public virtual int Id { get; set; }
public virtual string Titulo { get; set; }
public virtual IList<Image> Images { get; set; ...
I made a test class against the repository methods shown below:
public void AddFile<TFileType>(TFileType FileToAdd) where TFileType : File
{
try
{
_session.Save(FileToAdd);
_session.Flush();
}
catch (Exception e)
{
if (e.InnerException.Message.Contains("Violation of UNIQUE KEY"))
throw new Argum...
i'm working w/ a legacy database is set-up stupidly with an index composed of a char id column and two char columns which make up a date and time, respectively. I have created a ICompositeUserTypefor the date and time columns to map to a single .NET DateTime property on my entity, which works by itself when not part of the id. i need t...
The setup
Some of the "old old old" tables of our database use an exotic primary key generation scheme [1] and I'm trying to overlay this part of the database with NHibernate. This generation scheme is mostly hidden away in a stored procedure called, say, 'ShootMeInTheFace.GetNextSeededId'.
I have written an IIdentifierGenerator that c...
I have a bidirectional relationship in NHibernate:
<class name="Child" table="Children">
<many-to-one name="Parent" column="ParentId" not-null="true" />
</class>
<class name="Parent">
<set name="Children" lazy="true" table="Children" cascade="all">
<key column="ParentId" not-null="true" />
<one-to-many class="Child" />
</...
I was using regular session for loading some items from database via linq. The problem is that it caches the entities and memory load increases very much unnecessarily. Is there a way to replace session with stateless session without introducing many changes in client code?
...
I'm using NHibernate to persist a many-to-many relation between Users and Networks. I've set up both the User and Network class as follows, exposing each's collections as ReadOnlyCollections to prevent direct access to the underlying lists. I'm trying to make sure that the only way a User can be added to a Network is by using its "JoinNe...
My main application form (WinForms) has a DataGridView, that uses DataBinding and Fluent NHibernate to display data from a SQLite database. This form is open for the entire time the application is running.
For performance reasons, I set the convention DefaultLazy.Always() for all DB access.
So far, the only way I've found to make this...
I'm working on setting up NHibernate for a project and I have a few queries that, due to their complexity, we will be leaving as stored procedures. I'd like to be able to use NHibernate to call the sprocs, but have run into an error I can't figure out. Since I'm using Fluent NHibernate I'm using mixed mode mapping as recommended here. H...
I have the following (simplified)
public enum Level
{
Bronze,
Silver,
Gold
}
public class Member
{
public virtual Level MembershipLevel { get; set; }
}
public class MemberMap : ClassMap<Member>
{
Map(x => x.MembershipLevel);
}
This creates a table with a column called MembershipLevel with the value as the Enum st...
Hi all,
I think I am at a impasse here. I have an application I built from scratch using FluentNHibernate (ORM) / SQLite (file db). I have decided to implement the Unit of Work and Repository Design pattern. I am at a point where I need to think about the end game, which will start as a WPF windows app (using MVVM) and eventually implem...
I'm having some trouble using nHibernate, automapping and a class structure using multiple chains of abstract classes
It's something akin to this
public abstract class AbstractClassA {}
public abstract class AbstractClassB : AbstractClassA {}
public class ClassA : AbstractClassB {}
When I attempt to build these mappings, I receive ...
How I can lookup a specific date in Nhibernate?
I'm currently using this to lookup one day's order.
ICriteria criteria = SessionManager.CurrentSession.CreateCriteria(typeof(Order))
.Add(Expression.Between("DateCreated", date.Date.AddDays(-1), date.Date.AddDays(1)))
.AddOrder(NHibernate.Criterion.Order.Desc("Ord...
I'm running into an issue with private setters when using NHibernate and lazy-loading. Let's say I have a class that looks like this:
public class User
{
public virtual int Foo {get; private set;}
public virtual IList<User> Friends {get; set;}
public virtual void SetFirstFriendsFoo()
{
// This line works in a un...
I am trying to do versioning with NHibernate and everything works fine, however right after the insert NHibernate tries to pull the generated timestamp by executing the following query:
SELECT profileloc_.Updated as Updated14_ FROM profile_locale profileloc_
WHERE profileloc_.id=?p0 and profileloc_.culture=?p1;?p0 = 16, ?p1 = 1033
Wh...
Note: Now that I've typed this out, I have to apologize for the super long question, however, I think all the code and information presented here is in some way relevant.
Okay, I'm getting odd "Session Is Closed" errors, at random points in my ASP.NET webforms application. Today, however, it's finally happening in the same place over ...
I know SysCache uses ASP caching under the hood, but since I'm not aware of the implementation of the ASP cache (and if it depends on anything IIS), I was wondering if SysCache would work in a non-web application (like a Windows Service)?
Activating it and using NHprofiler seems to show it is not.
...
I'm using NHibernate 2.1.2 and Spring 1.3
I have two Text columns (blobs) in one of my classes. I'm trying to use lazy="true" for the mapping of those properties but NHProfiler still shows the two columns being added to the SELECT statement when the main object is loaded.
I'm using Spring.NHibernate session factory and have configured ...
I found this tool Visual NHibernate at http://www.slyce.com/, but a search on here has not brought anything up for what I would have thought would have been a very popular product, in concept anyway.
Has anyone used this product? Any feedback on it?
Thanks
...
I'm using the following mapping:
public class LoadMap : IAutoMappingOverride<Load> {
public void Override(AutoMapping<Load> mapping) {
mapping.HasMany(x => x.Bids).OptimisticLock.None();
mapping.Version(x => x.Version);
}
}
But when I try to create the session I get the following exception:
[FormatException...