I have a transient object I'm using for data binding to my UI
LookupDTO and I have a mapped class called
Market.
I'm trying the following HQL query to construct a list of LookupDTO objects using the values from the mapped class as follows:
Code:
return session.CreateQuery
("SELECT new LookupDTO(Id, Id) FROM Market").List<LookupDTO>();
I'm getting the following error:
Code:
NHibernate.QueryException: class not found: LookupDTO [SELECT new LookupDTO(Id, Id) FROM TransAlta.DealManagement.Domain.Market.Market]
The error indicates that I'm missing a reference somewhere, but I'm not sure which dll. I'm referencing the NHibernate.dll.
Any help would be much appreciated...
Greg
Code Below...
LookupDTOCode:
[Serializable]
public class LookupDTO
{
private string key;
private string text;
public LookupDTO()
{
}
public LookupDTO(string key, string text)
{
this.key = key;
this.text = text;
}
public string Key
{
get { return key; }
set { key = value; }
}
public string Text
{
get { return text; }
set { text = value; }
}
public override string ToString()
{
return text;
}
}
}
MarketCode:
public class Market : DomainObject<string>
{
}
public class DomainObject<T> : IDomainObject
{
private T id;
protected int version;
protected DateTime createDate;
protected DateTime lastModifiedDate;
protected string createBy;
protected string lastModifiedBy;
public virtual void SetId(object o)
{
id = (T) o;
}
public void MarkModified()
{
LastModifiedDate = DateTime.Now;
LastModifiedBy = Thread.CurrentPrincipal.Identity.Name;
}
public void MarkCreated()
{
Version = 1;
CreateDate = DateTime.Now;
CreateBy = Thread.CurrentPrincipal.Identity.Name;
MarkModified();
}
public virtual T Id
{
get { return id; }
set { SetId(value); }
}
public int Version
{
get { return version; }
set { version = value; }
}
public DateTime CreateDate
{
get { return createDate; }
set { createDate = value; }
}
public DateTime LastModifiedDate
{
get { return lastModifiedDate; }
set { lastModifiedDate = value; }
}
public string CreateBy
{
get { return createBy; }
set { createBy = value; }
}
public string LastModifiedBy
{
get { return lastModifiedBy; }
set { lastModifiedBy = value; }
}
public override bool Equals(object obj)
{
if (this == obj) return true;
DomainObject<T> _domainObject = obj as DomainObject<T>;
if (_domainObject == null) return false;
return Equals(id, _domainObject.id);
}
public override int GetHashCode()
{
return id.GetHashCode();
}
}
public interface IDomainObject
{
void SetId(object o);
void MarkModified();
void MarkCreated();
int Version { get; set; }
DateTime CreateDate { get; set; }
DateTime LastModifiedDate { get; set; }
string CreateBy { get; set; }
string LastModifiedBy { get; set; }
}
Mapping for MarketCode:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="TransAlta.DealManagement.Domain" namespace="TransAlta.DealManagement.Domain.Market">
<class name="Market" table="mrktc" lazy="false" mutable="false" where="mrktc_active='1' AND mrktc_futopt IN ('I', 'P')">
<id name="Id" column="mrktc_mkt" type="string" access="field.camelcase">
<generator class="native" />
</id>
</class>
</hibernate-mapping>