Hello, I have a problem mapping an Id. The structures of the entities are as follows:
public abstract class Entity<TEntity, TId>
where TEntity : Entity<TEntity, TId>
{
public virtual TId Id { get; protected set; }
public override bool Equals(object obj)...
...
}
public class EntityA<EntityA, long> : Entity<EntityA, long...
Basically I'm trying to do the same thing as this question but with Fluent NHibernate.
Here is my id generation convention:
public class IdGenerationConvention : IIdConvention
{
public void Apply(IIdentityInstance instance)
{
instance.GeneratedBy.HiLo("1000");
}
}
Now this works ...
Yes, nit-picky is a good way to describe this... ;)
Does anyone know if you can specify the table and/or column names to use HiLo using Fluent NHibernate? Currently the schema export creates this...
create table hibernate_unique_key (
next_hi INTEGER
)
...
I compiled the fluent nhibernate 1.0 rc with nhibernate 2.1 and had several warnings after the errors were fixed.
Fluent nhibernate tells me to use a separate Subclass-map instead of JoinedSubclass.
Current Mapping:
public class ClientMap : ClassMap<Client>
{
public ClientMap()
{
LazyLoad();
Id(x => x.Id);
...
Very new to FluentNHibernate, but I'm also excited about the area. I've recently started work on a new DAL using the aforementioned and have been reading up on the Repository pattern. I like the generic form this pattern takes and am looking to use this pattern in conjunction with the UnitOfWork pattern for session management.
I'm curio...
Using the method described in NHibernate & INotifyPropertyChanged, the repository will return a collection of proxies that implement INotifyPropertyChanged, but on some objects when saving or deleting it will throw an error:
at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName)
at NHibernate.Impl.SessionImpl....
I am using NHibernate/Fluent NHibernate in an ASP.NET MVC app with a MySQL database. I am working on an operation that reads quite a bit of data (relative to how much is inserted), processes it, and ends up inserting (currently) about 50 records. I have one ISession per request which is created/destroyed in the begin/end request event ha...
how to disable lazy loading in fn r1.0?
...
I have an existing class that I'd like to persist as-is.
class Foo
{
public int Id;
...
}
I have the following ClassMap:
class FooMap : ClassMap<Foo>
{
Id(x => x.Id);
...
}
Building a session factory results in an invalid cast exception. My setup works if my entity class has the standard "public virtual int Id { get...
I'm new to NHibernate and FNH as well. I'm familiar with ORM's and decided to see what all the buzz was about with this particular one mostly because of the productivity gains. At this point I think my time would have been better spent using something else but I don't want to let this defeat me and I'm hoping it's a stupid error I'm ma...
I have a simple three table DB with many-to-many relation.
A(id, Name)
B(id, Name)
AB(AId, BId) references A and B
The corresponding classes:
public class A
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
}
public class B
{
public virtual int Id { get; set; }
public virtual string Name ...
I've been struggling with this for 2 days now so i thought i would give it a shot here.
my scenario looks like this. i got a Customer and CustomerPhone. Now i save the Customer and CustomerPhone at the same time but the CustomerPhone doesn't get Id right away. but if i do a redirect to a other site and get the Customer object there the ...
Let say I'm doing a basic transaction system where I have the following objects.
public class User
{
public virtual int Id{get; set;}
}
public class Transaction
{
public virtual int Id{get; set;}
public virtual Item Item {get; set;}
public virtual User Seller{get; set;}
public virtual User Buyer{get; set;}
}
Notice how...
Hi
I need to map a class which has a list of Enums to a db table, using NHibernate
here are the objects
public class Driver : IIdentity
{
private IList<Licence> licences;
/// <summary>
/// The drivers licences
/// </summary>
public virtual IList<Licence> Licences
{
get
{
return this...
Hi, i have the following code, which is supposed to give specific functionality but it isn't :S
anyway, here's my problem:
http://img525.imageshack.us/img525/1315/diagramp.png
here's the mapping code:
public class UsersMap : ClassMap<User>
{
public UsersMap()
{
this.Table("Users");
Id(x => x.UserName).Generat...
I want to add an event listener (IPreUpdateEventListener) to add NH but I can't seem to find an example when using a fluent configuration.
I want to be able to add the listener when I create the session factory, e.g. when the following code is execute.
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfigura...
I am trying to implement a post tagging systems into my Blog and decided to attempt to implement the Toxi solution from here: http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html.
I currently have two POCO classes designed. One for Post and one for Tag
public class Post
{
public int ID { get; set; }
...
Hi,
I'm looking for a point in the right direction to solving this problem.
I am being passed an object from the ui.
One of the values is for a foreign key (an int which allows nulls). The value being sent is -1 which signifies that the value has not been set by the user.
How can I write this object to the db setting the foreign key ...
this is my db:
tblGroups:
GroupID
GroupName
tblMembersInGroup
GroupID
MemberID
Rank
tblMembers
MemberID
Name
this is my Model:
class group
{
int groupid
string name
List<EnlistedMembers> myMembers;
}
class EnlistedMebmers
{
Member myMember;
int Rank;
}
class Member
{
int MemberID
string Name
}
I am not sure how...
Can anybody confirm that this does not work as expected, as I am getting an error that it is trying to access property rather then trying to access field.
private IList<MetaPackage> _metaPackages;
public virtual IEnumerable<MetaPackage> MetaPackages
{
get
{
return _metaPackages;
}
}
Fluent mapping
HasMany<MetaPackage>(x
=...