2
I am trying to transform the data returned from the database to the settings made in my mapping, however I get the following criticism:
"The value "System.Object[]" is not "Domain.Classes.Classeemplo" and cannot be used in this generic collection."
I’ve tried using the "Transformers.Aliastoben", however I realized that ignores all my mapping. I am still very new in this area, if anyone can help me I thank you.
My Class:
public class ClasseExemplo
{
public virtual int ID { get; set; }
public virtual string Descricao { get; set; }
public virtual Usuario Usuario { get; set; }
public virtual DateTime TimeStamp { get; set; }
}
Mapping:
public ClasseExemploMap()
{
Id(x => x.ID);
Map(x => x.Descricao);
Refereces(x => x.Usuario).Column("USUARIO_ID").Cascade.None();
Map(x => x.TimeStamp);
Table("TABELA");
}
Repository:
public IList<ClasseExemplo> BuscarLista(int usuario)
{
string SQL = "select * " +
"from MinhaTabela " +
"where Usuario_ID = :id";
return Session.CreateSQLQuery(SQL)
.SetParameter("id", usuario)
//.SetResultTransformer(Transformers.AliasToBen(typeof(ClasseExemplo))
.List<ClasseExemplo>();
}
Don’t have the User_id field? At least in your class and map code
– novic
Thank you for the reply Virgilio, I had forgotten to mention the Column on my mapper, but the error still persists.
– Emanuel Lucas
How is this table and a test takes that generic and checks the return with List ()
– novic
Can not understand very well, I really need to return the values molded to my class, it is not possible to return the values only with List().
– Emanuel Lucas