Does not longer work with postgrsql for dotnet core : Npgsql 3.x removed support for ...

Does not longer work with postgrsql for dotnet core : Npgsql 3.x removed support for ...

magnus@greatlord.commagnus@greatlord.com Posts: 16Questions: 6Answers: 0

I am using DataTable.net editor for dotnet core with postgrsql

Npgsql 3.x removed support for writing a parameter with an IEnumerable value, use .ToList()/.ToArray() instead

Answers

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Thank you - I wasn't aware of that. I've filed a bug internally so we get it fixed for the next release.

    Allan

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    I've just been looking into this one and we actually use Npgsql 4.0.3 in our demo scripts and it appears to work okay.

    You mention Npgsql 3, but 4.0 was released in 2018.

    I realise this is an old post now, but using Npgsql 4.x should work no problem.

    Allan

  • magnus@greatlord.commagnus@greatlord.com Posts: 16Questions: 6Answers: 0

    Hi sorry for late answers
    <PackageReference Include="Dapper" Version="2.0.35" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    <PackageReference Include="Npgsql" Version="4.1.3.1" />
    <PackageReference Include="OrchardCore.Localization.Core" Version="1.0.0-rc1-10004" />
    <PackageReference Include="Tortuga.Chain.PostgreSql" Version="3.3.2" />

    as u can see I am using Npgsql and postgrsql 12, under debian 10

    and datatable library 1.9.0 to 1.9.3 gives me follow error
    Npgsql 3.x removed support for writing a parameter with an IEnumerable value, use .ToList()/.ToArray() instead

    <

    script>
    jQuery(document).ready(function ($) {

            let editor = new $.fn.dataTable.Editor({               
                ajax: {
                    create: {
                        type: 'POST',
                        url: '/restapi/backend/CreateUser'
                    },
                    edit: {
                        type: 'POST',
                        url: '/restapi/backend/EditUser'
                    },
                    remove: {
                        type: 'POST',
                        url: '/restapi/backend/DeleteUser'
                    }
                },
                //ajax: '/restapi/backend/users',
                table: '#tbl_user',
                fields: [
                    {
                        "label":  "@Localizer["fristname"]:",
                        "name": "fristname"
                    },
                    {
                        "label": "@Localizer["lastname"]:",
                        "name": "lastname"
                    },
                    {
                        "label":  "@Localizer["email"]:",
                        "name": "email"
                    },
                    {
                        "label": "@Localizer["password"]:",
                        "name": "password"
                    },
                    {
                        "label":  "@Localizer["supper admin"]:",
                        "name": "superadmin",
                        "type": "checkbox",
                        "options": [
                            { label: '', value: 1 }
                        ]
                    },
                ]
            });
    
    
            var table = $('#tbl_user').DataTable({
                dom: 'Bfrtip',
                ajax: '/restapi/backend/GetUsers',
                @Html.Raw(tblLng)
                columns: [
                    {
                        "data": "fristname"
                    },
                    {
                        "data": "lastname"
                    },
                    {
                        "data": "email"
                    },
                    {
                        "data": "password",
                        "render": function (data, type, row, meta) {
                            return '********';
                        }
                    },
                    {
                        "data": "superadmin",
                        "render": function (data, type, row, meta) {
                            let html = '';
    
                            if (row.superadmin) {
                                html = '<input type="checkbox" checked disabled />';
                            } else {
                                html = '<input type="checkbox" disabled />';
                            }
    
                            return html;
                        }
                    }
                ],
                select: true,
                lengthChange: false,
                buttons: [
                    { extend: 'create', editor: editor },
                    { extend: 'edit', editor: editor },
                    { extend: 'remove', editor: editor }
                ]
            });
    

    the c# part

    [Authorize(Roles = "Super Adminstrators")]
    [Route("restapi/backend/GetUsers")]
    [HttpGet]
    [HttpPost]
    public ActionResult GetUsers()
    {

            long draw;
    
            draw = this.GetQueryLong("draw");
    
            // make sure no delete/create/edit is pass down here
            if (this.GetFormString("action") != null)
            {
                return Json(new { });
            }
    
            using (var db = new Database("postgres", PostgrSql.conStr))
            {
    
                DataTables.DtResponse response = new Editor(db, "public.user", "iduser")
                    .Model<tblUserModel>()
                    .Process(Request)
                    .Data();
    
                return Json(new
                {
                    draw = draw,
                    recordsTotal = response.recordsTotal,
                    recordsFiltered = response.recordsFiltered,
                    data = response.data,
                    options = response.options,
                    error = response.error
                });
    
            }
    
        }
    
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    If you add .TryCatch(false) just before the .Process(...) call does it tell you what line the error is happening on? Or is this a compile time error? In which case, does the compiler tell you the error?

    I don't understand why this would be happening unless Tortuga.Chain.PostgreSql is pulling in an old version?

    Allan

This discussion has been closed.