我正在尝试为正在运行的HQL查询创建DTO对象,但是,当从我的存储库执行我的HQL查询时,它会产生NH强制转换错误:
System.InvalidCastException: Unable to cast object of type 'NHibernate.Hql.Ast.ANTLR.Tree.SqlNode' to type 'NHibernate.Hql.Ast.ANTLR.Tree.FromReferenceNode'.
以前有人遇到过这个吗?
我的DTO映射和课程如下:
/// <summary>
/// TODO: Update summary.
/// </summary>
public class TaskListItemMapping : ClassMap<TaskListItem>
{
public TaskListItemMapping()
{
ImportType<TaskListItem>();
Id(x => x.TaskCode).GeneratedBy.Assigned();
}
}
/// <summary>
/// A class representing a task list data query result
/// </summary>
public class TaskListItem
{
public virtual int Code { get; set; }
public virtual String Client { get; set; }
public virtual string Matter { get; set; }
public virtual DateTime DueDate { get; set; }
public virtual bool Notepad { get; set; }
public virtual bool Flag { get; set; }
public virtual string Client { get; set; }
public virtual string Issue { get; set; }
public virtual string Grade { get; set; }
public virtual String TaskInitials { get; set; }
public virtual string Description { get; set; }
public TaskListItem()
{
}
}
任何想法都赞赏!
答案 0 :(得分:0)
我发现了造成这种情况的原因 - 它与构造函数中的数据不匹配