Hello,
I have the following mapping...
public SalesMap ( )
{
this.Table ( "sales" );
this.LazyLoad ( );
this.Id ( x => x.SalesNo ).GeneratedBy.Identity ( ).Column ( "sales_no" );
this.References ( x => x.MasterSalesNo ).Column ( "master_sales_no" );
this.Map ( x => x.Record ).Column ( "record" ).Not.Nullable ( ).Not.Insert ( ).Not.Update ( ).Generated.Always ( );
this.Map ( x => x.Timestamp ).Column ( "timestamp" ).Not.Nullable ( ).Not.Insert ( ).Not.Update().Generated.Always() ;
this.Map ( x => x.CreatedBy ).Column ( "created_by" ).Not.Nullable ( ).Length ( 8 ).CustomSqlType ( "varchar(8)" );
this.Map ( x => x.CreateTime ).Column ( "create_time" ).Not.Nullable ( );
this.Map ( x => x.UpdatedBy ).Column ( "updated_by" ).Not.Nullable ( ).Length ( 8 );
this.Map ( x => x.UpdateTime ).Column ( "update_time" ).Not.Nullable ( );
this.Map ( x => x.EntryDate ).Column ( "entry_date" ).Not.Nullable ( );
this.Map ( x => x.OrderSts ).Column ( "order_sts" ).Not.Nullable ( ).Length ( 2 );
this.Map ( x => x.PrevOrderSts ).Column ( "prev_order_sts" ).Not.Nullable ( ).Length ( 2 );
this.Map ( x => x.FixedRateFlag ).Column ( "fixed_rate_flag" ).Not.Nullable ( );
this.Map ( x => x.RequestTime ).Column ( "request_time" );
this.Map ( x => x.BillOnShipFlag ).Column ( "bill_on_ship_flag" ).Not.Nullable ( );
this.Map ( x => x.CustomerPoNo ).Column ( "customer_po_no" ).Not.Nullable ( ).Length ( 30 );
this.Map ( x => x.Document ).Column ( "document" ).Not.Nullable ( ).Length ( 20 );
this.Map ( x => x.UserDefined1 ).Column ( "user_def1" ).Not.Nullable ( ).Length ( 40 );
this.Map ( x => x.UserDefined2 ).Column ( "user_def2" ).Not.Nullable ( ).Length ( 40 );
this.Map ( x => x.UserDefined3 ).Column ( "user_def3" ).Not.Nullable ( ).Length ( 40 );
this.HasMany ( x => x.SalesSet ).KeyColumn ( "master_sales_no" );
}
when it saves it to the database, i get the following error...
Msg 8152, Level 16, State 2, Line 1
String or binary data would be truncated.
The statement has been terminated.
This is the query that is generated by NHibernate...
exec sp_executesql N'INSERT INTO sales (created_by, create_time, updated_by, update_time, entry_date, order_sts, prev_order_sts, fixed_rate_flag, request_time, bill_on_ship_flag, customer_po_no, document, user_def1, user_def2, user_def3, master_sales_no) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14, @p15); select SCOPE_IDENTITY()',N'@p0 nvarchar(4000),@p1 datetime,@p2 nvarchar(4000),@p3 datetime,@p4 datetime,@p5 nvarchar(4000),@p6 nvarchar(4000),@p7 bit,@p8 datetime,@p9 bit,@p10 nvarchar(4000),@p11 nvarchar(4000),@p12 nvarchar(4000),@p13 nvarchar(4000),@p14 nvarchar(4000),@p15 int',@p0=N'nexterna',@p1='2012-06-28 12:53:31',@p2=N'nexterna',@p3='2012-06-28 12:53:31',@p4='2012-06-28 12:53:31',@p5=N'ordersts',@p6=N'prevordersts',@p7=1,@p8='2012-06-28 12:53:31',@p9=1,@p10=N'123',@p11=N'document',@p12=N'userdef1',@p13=N'userdef2',@p14=N'userdef3',@p15=5000002
How do i stop it from creating the nvarchar(4000) fields?
Thanks