このコードにエラーがあり、その理由がわかりません。
私のコードは2つのファイルで構成されています:
systemprop.cs
System.hbm.xml
しかし、次のエラーがあります。
Erreur de syntaxe près de '[propertyID] as column1_19_, systemprop0_.[value] as column2_19_, systemprop0_.[' à la ligne 1"
これは、1 行目の , の近くに構文エラーがあることを意味します'[propertyID] as column1_19_, systemprop0_.[value] as column2_19_, systemprop0_.['
。
これが私のコードです:
クラスSystemprop
:
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using DATA;
namespace DATA
{
public partial class Systemprop
{
private string PropertyID { set; get; }
private string Value { set; get; }
private string Description { set; get; }
private int LastUpdateTime { set; get; }
private int CreationTime { set; get; }
// public Systemprop() { }
public static ISessionFactory SessionFactory;
public static ISession OpenSession()
{
if (SessionFactory == null)
{
Configuration config = new Configuration();
config.SetProperty(NHibernate.Cfg.Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
config.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.Dialect.MySQLDialect");
config.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.Driver.MySqlDataDriver");
config.SetProperty(NHibernate.Cfg.Environment.ConnectionString, "Server=localhost;Database=opengts;Uid=root;Pwd=;");
config.AddAssembly("DATA");
SessionFactory = config.BuildSessionFactory();
}
return SessionFactory.OpenSession();
}
public static IList<Systemprop> GetSystemprop()
{
using (ISession session = OpenSession())
{
if (session != null)
{
IQuery query = session.CreateQuery("FROM Systemprop");
IList<Systemprop> pets = query.List<Systemprop>();
return pets;
}
}
return null;
}
}
}
Systemprop.hbm.xml
:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="DATA" assembly="DATA">
<class name="Systemprop" table="[dbo].[systemprops]" >
<id name="PropertyID" column="[propertyID]" type="String" length="32" >
<generator class="assigned" />
</id>
<property name="Value" column="[value]" type="String" not-null="false" length="16" />
<property name="Description" column="[description]" type="String" not-null="false" length="128" />
<property name="LastUpdateTime" column="[lastUpdateTime]" type="Int32" not-null="false" />
<property name="CreationTime" column="[creationTime]" type="Int32" not-null="false" />
</class>
</hibernate-mapping>
しかし、私はこのエラーがあります:
[MySqlException (0x80004005): Erreur de syntaxe près de '[propertyID] as column1_19_, systemprop0_.[value] as column2_19_, systemprop0_.[' à la ligne 1]
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +277
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId) +73
MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int32& insertedId) +20
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +100
MySql.Data.MySqlClient.MySqlDataReader.NextResult() +742
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +1620
MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +4
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() +12
NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) +292
NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) +244
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +186
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +129
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +116
[GenericADOException: could not execute query
[ select systemprop0_.[propertyID] as column1_19_, systemprop0_.[value] as column2_19_, systemprop0_.[description] as column3_19_, systemprop0_.[lastUpdateTime] as column4_19_, systemprop0_.[creationTime] as column5_19_ from [dbo].[systemprops] systemprop0_ ]
[SQL: select systemprop0_.[propertyID] as column1_19_, systemprop0_.[value] as column2_19_, systemprop0_.[description] as column3_19_, systemprop0_.[lastUpdateTime] as column4_19_, systemprop0_.[creationTime] as column5_19_ from [dbo].[systemprops] systemprop0_]]
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +213
NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) +18
NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) +79
NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters) +51
NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters) +231
NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results) +369
NHibernate.Impl.SessionImpl.List(String query, QueryParameters queryParameters, IList results) +317
NHibernate.Impl.SessionImpl.List(String query, QueryParameters parameters) +282
NHibernate.Impl.QueryImpl.List() +163
DATA.SystempropExtensions.GetSystemprop() in C:\Users\HP\Desktop\our_project\DATA\Queries\Systemprop.cs:37
MvcApplication7.Controllers.AccueilController.Index() in C:\Users\HP\Desktop\our_project\MvcApplication7\Controllers\AccueilController.cs:16
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
どうすればこの問題を解決できますか?