I've got a class something like this:
public class Account
{
public virtual int Id { get; private set; }
public virtual string Username { get; set; }
[EditorBrowsable( EditorBrowsableState.Never )]
public virtual string Password { get; private set; }
public void SetPassword( string password ){ ... }
public bool CheckPassword( st...
I've got two theoretical domain objects:
public class Person
{
public virtual int Id { get; private set; }
}
public class PersonMap : ClassMap<Person>
{
public PersonMap() { Id( x => x.Id ); }
}
public class DriversLicense
{
public virtual Person Person { get; set; }
public virtual string State { get; set; }
}
public ...
I have two tables (Section and SectionList) that are related by a many to many table (Membership). Since there is an extra property in the many to many table, i have to break it out into its own entity:
public MembershipMap()
{
UseCompositeId()
.WithKeyReference(x => x.Section, "SectionId")
.WithKeyReference(x => x.SectionLis...
Further to my other question given the following classes and fluent map, is there any way to automatically cascade delete a DriversLicense when the related Person is deleted? Note, I do not want the Person class to have any knowledge of the DriversLicense class, but I also don't want orphaned data if a Person gets deleted.
public class ...
As the title says, is it possible to get hands on the XML representation of a fluent nhibernate mapping? And if it is, can this be used directly with Hibernate for Java?
...
We have been having this issue pop up sporadically, but now I can reproduce it every time. I am incrementing a view counter on my custom built forums, which causes an error:
NHibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
This error occurs on another collection in ...
I have tried using the Reveal property in Fluent but I can't get it to compile with a collection. I want one of my collections in an entity to be protected and not accessible anywhere except in the entity itself. Is this possible? Thanks
Edit:
Here's the code I'm trying to use,
HasMany<Trip>(x => Reveal.Property<Trip>("_trips"));
I'...
Hello,
I have to build a website for a news channel..
Please help me decide which technology to use for data operations?
1) Linq to Entities
2) Linq to SQL
3) Fluent NHibernate
4) ADO.Net
Website will be based on ASP.Net MVC and C#.
Main Issues:
1) Should be easy to maintain and scale.
2) Good Performance
Please express your vie...
Hi
I am a newbie with Fluent NHibernate and have got a question that may not be asked correctly, so please bear with me.
I am a bit confused about the best way to manage NHibernate sessions in a web application using Fluent NHibernate.
I have read this post but am unsure whether I need to apply this method to my web application or whe...
How do I let NHibernate ignore extra properties of a subclass of my model?
class SuperModel { // hot I know
{
public Guid Id { get; private set; }
public string FirstName { get; set; }
}
class SubModel : SuperModel {
public string FavoriteColor { get; set; }
}
I really only want to store the SuperModel data using my repos...
I would like to create a convention class that would ignore properties staring with certain
prefix like "ig_". I did try implementing IPropertyConvention interface and calling clear() on columnname property. But this didn't work. Any ideas?
Thanks
- Fahad
...
Is it possible to have an integer property of a class auto increment managed by the database but not be a primary key (or Id as NHibernate refers to them)? I'm having trouble finding examples of how to do this. Any help would be appreciated. Thanks.
...
I am automapping measurement classes (that implement interface IMeasurement) as components.
This works fine, but I have some attributes in the components I would like to ignore.
Apparently I cannot use IgnoreProperty on the measurement classes themselves, i.e.:
[ .ForTypesThatDeriveFrom(p => p.IgnoreProperty(x => x._uomSpecified)) ]
w...
Hi,
I have entity User with one-to-many relationship to UserToUserCategories. When I load user from database, do not change it and than flush the session, NHibernate will performs UPDATE of the user and increment it's version. It seems to me as unwanted behaviour, imagine that I load hundred of users and NHibernate would update them all...
Hello:
The focus of this question is primarily to develop a relational db scheme given the object model here.
This part of the system is concerned with time based allocations made by Resources (different flavors of Employees & Contractors) to Activities (either a Project or an Account). Data entry is weekly, and the domain model must v...
I have a class that looks like this:
public class Job
{
public Company Company {get;set;}
public Job JobForCompanyA {get;set;}
public Job JobForCompanyB {get;set;}
}
The jobs for the two companies will reference each other, for example:
var jobA = new Job { Company = Company.CompanyA };
var jobB = new Job { Company = Comp...
i have a complex entity, very very heavy.
i want to select only the id and the name of this entity from the db for a better performance.
how do i do that with nhibernate (or fluent nhibernate).
...
I have a SQL Server DB with a recursive table:
MyTable:
ID : string PrimaryKey
Parent: string references MyTable - NOTNULL !!
and map with Fluent NHibernate to
class MyTable
{
public virtual string ID {get; set;}
public virtual MyTable Parent {get; set;}
}
My problem is that Parent should be null in my C# app if the column Pa...
First, I have the following table:
CREATE TABLE CustomerHub (
CustomerId INT NOT NULL,
HubId INT NOT NULL
)
Which I have mapped to the this entity:
public class CustomerHub
{
public int CustomerId {get;set;}
public int HubId {get;set}
//GetHashCode, Equals, Etc...
}
Using this mapping:
public class CustomerHubMap :...
Hi,
I have a IIdConvention for my Fluent NHibernate mapping:
public class SplitIDNameConvention : IIdConvention
{
public bool Accept(IIdentityPart target)
{
return true;
}
public void Apply(IIdentityPart target)
{
if (target.GetColumnName() == null)
target.ColumnName(SplitName(target.Pro...