I have two assemblies: BLL and BLL.Interface
BLL.Interface contains interfaces of the bussiness entities. For example:
public interface IVartotojai
{
#region Public Properties
int Userid{get; set;}
string UserName{get; set;}
ISkyriai Skyriausid{get;set;}
}
BLL assembly has concrete implementation and mapping files. Mapping file looks like this:
using System;
using System.Collections;
using System.Collections.Generic;
using NmpkStatistika.BLL.Interface.Entities;
namespace NmpkStatistika.BLL.Entities
{
/// <summary>
/// Vartotojai object for NHibernate mapped table 'Vartotojai'.
/// </summary>
[Serializable]
public class Vartotojai : ICloneable,IVartotojai
{
#region Member Variables
protected int _userid;
protected string _username;
protected ISkyriai _skyriausid;
public virtual int Userid
{
get { return _userid; }
set { _bIsChanged |= (_userid != value); _userid = value; }
}
public virtual string UserName
{
get { return _username; }
set
{
if (value != null && value.Length > 50)
throw new ArgumentOutOfRangeException("UserName", "UserName value, cannot contain more than 50 characters");
_bIsChanged |= (_username != value);
_username = value;
}
}
public virtual ISkyriai Skyriausid
{
get { return _skyriausid; }
set { _bIsChanged |= (_skyriausid != value); _skyriausid = value; }
}
}
Mapping file like this:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NmpkStatistika.BLL.Entities.Vartotojai,BLL" table="Vartotojai" lazy="true" proxy="NmpkStatistika.BLL.Interface.Entities.IVartotojai,BLL.Interface">
<id name="Userid" column="UserID" type="int">
<generator class="native" />
</id>
<property type="string" not-null="true" length="50" name="UserName" column="[UserName]" />
<many-to-one name="Skyriausid" cascade="none" column="SkyriausID" not-null="true" />
</class>
</hibernate-mapping>
I allways getting error that there is unmapped entity ISkyriai... If I comment out ISkyriai mapping part from Vartotojai.hbm.xml, I can query data that way:
session.CreateCriteria(typeof(IVartotojai)).List<IVartotojai>();
or
session.CreateCriteria(typeof(Vartotojai)).List<IVartotojai>();
So, I think nHibernate knows that IVartotojai = Vartotojai...
Tried create class section for interface with subclas section for concrete class, but nhibernate needs discriminator value, which I don't have...
How can I make this?
Skiv
P.S.: sorry for my poor english.
|