It seems like the following scenario shouldn't be uncommon, but I can't figure out how to handle it in FluenNHibernate:
public class Product: BaseEntity
{
public Product()
{
Categories = new List<Category>();
}
public virtual IList<Category> Categories { get; set; }
...
}
public enum Categories
{
Classi...
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, 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);
...
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 have a class which I would like to map as a component onto any table which contains it:
public class Time
{
public int Hours { get; set; }
public int Minutes { get; set; }
public int Seconds { get; set; }
}
I would like to store this class as a bigint in the database - the same as how TimeSpan is stored but my class has ...
I have enabled 2nd level cache in FluentNHibernate:
Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.ConnectionString(connectionString)
.Cache(c => c.ProviderClass<SysCacheProvider>().UseQueryCache())
)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<PersonMap>())...
I'm trying to map myexisting database by Fluent NHibernate I get error:
The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'many-to-one' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespa...
I need to sort a result set by two columns, one of which is always NULL.
A simplified view of Database where the columns I wish to sort on look like :
ColumnA is from Table A
Column B, B1 is from table B
ColumnA ColumnB ColumnB1
U NULL NULL
P NULL NULL
L NULL NULL
NULL U NULL
NULL ...
Hi, i have the following db structure:
Users:
- UserID
- UserName
- FirstName
- LastName
...
UsersLog:
- UserLogID
- UserID
- UserName
- FirstName
- LastName
...
- DateCreated
The log table simply inserts a record against the user everytime an insert or edit is made. The reason i have the log table is that when an order is submitted...
Hi all,
Using Microsoft's designer for the Entity Framework (v3.5), I have created an Entity Model (*.edmx) with a generated *.Designer.cs class. I can persist my objects to MS SQL Server using the model without any problems.
I am new to NHibernate, and out of curiosity, I now would like to use my model with Fluent NHibernate and SQL...
I have a child table containing an id to the parent. This is a one to one mapping, but the child table might be missing values. I'm having problems mapping this without getting an error though... I've tried several things; mapping the same column, having distinct properties etc..
Parent table
int id
Child table
int parentid
Paren...
I have an entity Person:
public class Person
{
public virtual int Id {get; set; }
public virtual string FirstName { get; set; }
public virtual string MiddleName { get; set; }
public virtual string LastName { get; set; }
}
with the mappings:
public class PersonMap
{
public PersonMap()
{
Table(TABLE_NAME);
...
I have a query which has an Order By clause. The generated SQL from NHibernate looks like
ORDER BY coalesce(x.Company as x__.Company, y.Company) asc
This fails as 'as' is not allowed in Order by clause in MS SQL Server. Is there any way I can prevent aliasing?
The criteria query that I have written looks like:
var orderBy = Proj...
I have a class called Worker
public class Worker : BaseEntity
{
public virtual int WorkerID { get; set; }
public virtual string Name { get; set; }
public virtual IList<Indemnification> Indemnifications { get; set; }
}
public class Indemnification : BaseEntity
{
public virtual int IndemnificationID { get; set; }
pu...
public Parent GetByName(string Name)
{
return _session.CreateCriteria<Parent>()
.Add(Restrictions.Eq("Name", Name))
.SetFetchMode("Children", FetchMode.Eager)
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.UniqueResult<Parent>();
}
public ParentDetailVM GetMeAParent(string Name)
{
...
I'm trying to delete a database record using ASP.NET MVC, Fluent, and NHibernate. See the code below for examples of how I'm trying to accomplish this. I am able to Get, Update, and Insert records but Delete is not working. When the Delete() method gets called in the controller (top one) it throws an Exception (System.Data.SqlClient.SqlE...
Hi
I need to get into FluentNhibernate and NHibernate code so i rebuild the solutions
and used the new assemblies, but the problem is that there is an assembly called
NHibernate.ByteCode.Castle.Dll which refuses to load the my own version of Nhibernate
and keep telling me that the Public Token doesn't match, so where can i get the sour...
I would like to use FluentNHibernate to map an Active Directory user object to a POCO object but can't find a provider in the FluentNHibernate.Cfg.Db namespace that will allow me to setup the connection. This is the data layer of a WCF RIA Service. Is there a way to do this?
...