従来のSQLServerデータベースに接続しています。テーブルの1つに「Primary」という列名があります。そのため、スクリプトは失敗しています。
nhibernateによって生成されたスクリプト:SELECTlocations0_.CustomerID as CustomerID1_、locations0_.LocationID as LocationID1_、locations0_.LocationID as LocationID2_0_、locations0_.Primary as Primary2_0_、locations0_.CustomerID as CustomerID2_0_ FROM dbo.tblLocation location0_ WHERE location0_.CustomerID =?
クラス:
public class Location
{
public virtual int LocationID { get; set; }
public virtual Customer Customer { get; set; }
public virtual int? CustomerID { get; set; }
public virtual string LocationName { get; set; }
public virtual string Address1 { get; set; }
public virtual string Address2 { get; set; }
public virtual string Address3 { get; set; }
public virtual string City { get; set; }
public virtual string StateOrProvince { get; set; }
public virtual string PostalCode { get; set; }
public virtual datetime? LTimeStamp{ get;set; }
public virtual bool Primary { get; set; }
}
マップ:パブリッククラスTblLocationMap:ClassMap {
public TblLocationMap()
{
Table("tblLocation");
//LazyLoad();
Id(x => x.LocationID).GeneratedBy.Identity().Column("LocationID");
References(x => x.Customer).Column("CustomerID");
Map(x => x.LocationName).Column("LocationName").Length(50);
Map(x => x.Address1).Column("Address1").Length(200);
Map(x => x.Address2).Column("Address2").Length(200);
Map(x => x.Address3).Column("Address3").Length(200);
Map(x => x.City).Column("City").Length(100);
Map(x => x.StateOrProvince).Column("StateOrProvince").Length(100);
Map(x => x.PostalCode).Column("PostalCode").Length(20);
//Map(x => x.Primary).Column("Primary").Not.Nullable();
//Map(x => x.LTimestamp).Column("LTimestamp");
HasMany(x => x.Contacts).KeyColumn("LocationID");
}
sql:
CREATE TABLE [dbo]。[tblLocation]([LocationID] [int] IDENTITY(1,1)NOT NULL、[CustomerID] [int] NULL、[LocationName] nvarchar NULL、[Address1] nvarchar NULL、[Address2] nvarchar NULL 、[Address3] nvarchar NULL、[City] nvarchar NULL、[StateOrProvince] nvarchar NULL、[PostalCode] nvarchar NULL、[Primary] [bit] NOT NULL、[RecTimestamp] [timestamp] NULL、([LocationID] ASC)WITH( PAD_INDEX = OFF、STATISTICS_NORECOMPUTE = OFF、IGNORE_DUP_KEY = OFF、ALLOW_ROW_LOCKS = ON、ALLOW_PAGE_LOCKS = ON)ON [PRIMARY])ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
行く
GenericADOException:コレクションを初期化できませんでした:[Domain.Locations#466] [SQL:SELECT location0_.CustomerID as CustomerID1_、locations0_.LocationID as LocationID1_、locations0_.LocationID as LocationID2_0_、locations0_.LocationName as Location2_2_0_、locations0_.Address1 as Address3_2_0_、locations0_ .Address2 as Address4_2_0_、locations0_.Address3 as Address5_2_0_、locations0_.City as City2_0_、locations0_.StateOrProvince as StateOrP7_2_0_、locations0_.PostalCode as PostalCode2_0_、locations0_.Primary as Primary2_0_、locations0_.CustomerID as CustomerID2_0_ FROM dbo. ?]
内部例外:{"キーワード'Primary'の近くの構文が正しくありません。"}