The length of the string value exceeds the length configured in the mapping/parameter

前端 未结 5 1731
你的背包
你的背包 2020-12-28 12:28

I am trying to insert some very long text into a string prop - it worked perfectly fine with LinqToSql, now I have switched over to NHibernate and want to save the same enti

5条回答
  •  醉梦人生
    2020-12-28 13:06

    I hit a similar problem but using a CustomType (derived from IUserType). It turns out to be easier to fix than without a custom type. All you need to do is define SqlTypes to explicitly return the longer string length type you want.

    public SqlType[] SqlTypes
    {
        get
        {
            // Explicitly specify the string max length 
            return new SqlType[] { SqlTypeFactory.GetString(Int32.MaxValue / 2) };
        }
    }
    

    This solved the problem for us quite nicely.

提交回复
热议问题