以下代码有什么问题?
public IList<T> GetPostsByUser(object UserId)
{
using (var session = sessionFactory.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
var queryString = string.Format("SELECT C FROM {0} AS C WHERE UserId=:UserId", typeof(T));
return session.CreateSQLQuery(queryString).SetParameter("UserId", UserId).List<T>();
//return session.QueryOver<T>().List<T>().IsLike(UserId).List();
}
}
}
注意:UserId被强制转换为对象,但它的来源来自System.GUID
例外:
无法执行查询 [SELECT C FROM FNHRepository.Entites.Post AS C WHERE UserId=@p0] Name:UserId - Value:3010cd36-539c-4b32-a0fb-976bca58ad38 [SQL: SELECT C FROM FNHRepository.Entites.Post AS C WHERE用户 ID=@p0]