这个错误〜
Exception thrown: 'NHibernate.Exceptions.GenericADOException' in NHibernate.dll
Additional information: Unable to perform find[SQL: SQL not available]
错误图片
http://i.stack.imgur.com/UYI9W.png
编辑后的代码(也不起作用)
public ICollection<T> GetAllRecords()
{
using (var session = HibernateHelper.OpenSession)
{
var Kero = session.CreateCriteria(typeof(T)).List<T>();
if (Kero == null)
{
Kero = session.CreateCriteria(typeof(T)).List<T>();
}
return Kero;
}
}
编辑之前
public ICollection<T> GetAllRecords()
{
using (var session = HibernateHelper.OpenSession)
return session.CreateCriteria(typeof(T)).List<T>();
}
这个班级
namespace Phoenix.Hibernate
{
using NHibernate.Criterion;
using System.Collections.Generic;
/// <summary>
/// This class encapsulates a repository for a table in the server's database. The class contains a group of
/// background methods for processing database transactions, inherited by other table repository classes
/// defined in the calling server project.
/// </summary>
/// <typeparam name="T">The table domain structure being processed by the class.</typeparam>
public abstract class Repository<T> where T : class
{
/// <summary>
/// This method returns true if the key specified in the method arguments has a corresponding value in the
/// server's database. If the value could not be found using the specified key, this method will return false.
/// </summary>
/// <param name="key">The key being searched for.</param>
public bool ContainsKey(object key)
{
using (var session = HibernateHelper.OpenSession)
return session.Get<T>(key) != null;
}
/// <summary>
/// This method returns true if the key specified in the method arguments has a corresponding value in the
/// server's database. If the value could not be found using the specified key, this method will return false.
/// The object specified in the method arguments will be assigned a new value if the value exists.
/// </summary>
/// <param name="key">The key being searched for.</param>
public bool TryGetValue(object key, out T obj)
{
using (var session = HibernateHelper.OpenSession)
obj = session.Get<T>(key);
return obj != null;
}
/// <summary>
/// This method returns the row entry for an object if the key specified in the method arguments is found in
/// the server's database. If the value could not be found using the specified key, this method will null.
/// </summary>
/// <param name="key">The key being searched for.</param>
public T GetByIdentifier(object key)
{
using (var session = HibernateHelper.OpenSession)
return session.Get<T>(key);
}
/// <summary>
/// This method fills a general collection object with entries from the database. The entries added to
/// the collection are defined by criteria specified in the method arguments.
/// </summary>
/// <param name="property">The property name for the column to search by.</param>
/// <param name="value">The value to search for in the column specified.</param>
public ICollection<T> GetUniqueResults(string property, object value)
{
using (var session = HibernateHelper.OpenSession)
return session.CreateCriteria(typeof(T)).Add(Restrictions.Eq(property, value)).List<T>();
}
/// <summary>
/// This method fills a general collection object with specific entries from the database. The entries
/// added to the collection are defined by criteria specified in the method arguments.
/// </summary>
/// <param name="property1">The property name for the column to search by.</param>
/// <param name="value1">The value to search for in the column specified.</param>
/// <param name="property2">The property name for the column to search by.</param>
/// <param name="value2">The value to search for in the column specified.</param>
public ICollection<T> GetUniqueResults(string property1, object value1, string property2, object value2)
{
using (var session = HibernateHelper.OpenSession)
return session.CreateCriteria(typeof(T))
.Add(Restrictions.Eq(property1, value1)).Add(Restrictions.Eq(property2, value2)).List<T>();
}
/// <summary> This method returns a collection containing all entries from the database table. </summary>
public ICollection<T> GetAllRecords()
{
using (var session = HibernateHelper.OpenSession)
return session.CreateCriteria(typeof(T)).List<T>();
}
/// <summary>
/// This method returns the first entry found in the database table that matches the search criteria
/// specified in the method's arguments. If the result was not found, the method will return null.
/// </summary>
/// <param name="property">The property name for the column to search by.</param>
/// <param name="value">The value to search for.</param>
public T GetUniqueResult(string property, object value)
{
using (var session = HibernateHelper.OpenSession)
return session.CreateCriteria(typeof(T)).Add(Restrictions.Eq(property, value)).UniqueResult<T>();
}
/// <summary>
/// This method accepts a SQL query as a formatted string from the method's arguments, and executes the
/// query. Error handling should be handled by the parent function.
/// </summary>
/// <param name="query">The formatted SQL query string.</param>
public int ExecuteSQLQuery(string query)
{
using (var session = HibernateHelper.OpenSession)
return session.CreateSQLQuery(query).ExecuteUpdate();
}
}
}
任何人都可以帮助我吗?!