FreeSql icon indicating copy to clipboard operation
FreeSql copied to clipboard

Pgsql:jsonb类型映射C# List<int或者long>时,调用ExecuteInserted,ExecuteUpdated发生异常

Open yyylly opened this issue 4 years ago • 1 comments

Freesql:v3.2.3-3.2.6 实体:

[Table(Name = "public.test")]
    public class Test
    {
        [Column(Name = "id", IsPrimary = true, IsIdentity = true)]
        public int Id { get; set; }
        /// <summary> 
        /// 会员ID
        /// </summary>
        [Column(Name = "name")]
        public string Name { get; set; }
        /// <summary> 
        /// 会员ID
        /// </summary>
        [Column(Name = "ids",MapType =typeof(JArray))]
        public List<long> Ids { get; set; }
    }

测试方法:

public string jsonbTest()
        {
            var model = new Test() { Name="hahahah",Ids=new List<long> { 22} };

            /*
             * freesql:3.2.3
             * 
             * c#:
             * [Column(Name = "ids",MapType =typeof(JArray))]
             * public List<long> Ids { get; set; }
             * 
             * pgsql:jsonb
             */


            //异常:
            /*            
             * Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'System.String'.”
             */  
            var insertAndOut =_freeSql.Insert(model)
                .ExecuteInserted();

            //异常,和ExecuteInserted一样的错误
            var updateResult =_freeSql.Update<Test>()
                .SetSource(update1)
                .ExecuteUpdated();

            return "";
        }

yyylly avatar Apr 29 '22 09:04 yyylly

升级 FreeSql 到 3.2.603

升级 FreeSql.Provider.PostgreSQL 到 3.2.604(只发布了这个包,之后会再同步版本号)

2881099 avatar Apr 29 '22 11:04 2881099