Npgsql枚举错误

时间:2016-03-17 16:09:35

标签: npgsql

尝试使用Npgsql V3.05保持枚举时收到以下错误消息。

  

枚举必须通过Connection.RegisterEnumType或RegisterEnumTypeGlobally在Npgsql中注册

我在PostgrSQL中的PostgreSQL中创建了一个类型,并通过以下查询对其进行了验证:

<table class="table" id="NameList">
    <tr>
        <th>
            Full Name
        </th>
        <th>
            Time Remaining
        </th>
        <th></th>
    </tr>
</table>

 $(function () {

            var usersList = [];

            function init() {

                $.ajax({
                    url: '@Url.Action("GetNames", "UserNames")',
                    type: "GET",
                    dataType: "json",
                    cache: false,
                    async: true,
                    success: function (data) {

                        var row = null,
                            first = true,
                            timer = null;

                        // populate local users list:
                        usersList = data;

                        // populate HTML for table:
                        $.each(usersList, function (index, item) {
                            row = $('<tr id="row-' + item.Id + '"><td>' + item.FullName + '</td></tr>');

                            // add a timer to the first row:
                            if (first) {
                                $(row).append(getTimer());
                                first = false;
                            }

                            $('#NameList').append(row);
                        });

                    },
                    error: function (error) {
                        console.log(error);
                    }
                });        
            }
            init();

            function restartTimer() {

                var deletedElement = null,
                    nextId = null,            
                    newRow = null,
                    row = null,
                    that = this;

                    // remove the deleted item from local array:
                    deletedElement = usersList.shift();

                    // delete record from db on server:
                    $.ajax({

                        url: '@Url.Action("Delete", "UserNames")',
                        type: "POST",
                        data: ({ id: deletedElement.Id }),
                        dataType: "json",
                        cache: false,
                        async: true,
                        success: function (data) {

                            // remove this timer:
                            $(that).remove();

                            // add new record to local array:
                            usersList.push(data);

                            // add html for row:
                            newRow = $('<tr id="row-' + data.Id + '"><td>' + data.FullName + '</td></tr>');
                            $('#NameList').append(newRow);

                            //remove the html for deleted user:
                            $('#row-' + deletedElement.Id).remove();

                            if (usersList.length > 0) {

                                // get the next item id:
                                nextId = usersList[0].Id;

                                // add a timer to the new item:
                                row = $('#row-' + nextId);
                                row.append(getTimer());
                            }
                        }
                    });
            }

            function getTimer() {
                var timer = $('<td></td>');
                $(timer).countdown({
                    layout: '{mnn} : {snn}', timeSeparator: ':', until: 15, onTick: TimerColorChange, onExpiry: restartTimer
                });
                return timer;
            }

            function TimerColorChange(periods) {

                var seconds = $.countdown.periodsToSeconds(periods);
                if (seconds <= 3) {
                    $(this).css("color", "red");
                } else {
                    $(this).css("color", "black");
                }

            }
        });

返回

select enum_range(null::schedule_link_type);

我在我的VB.NET程序中创建了一个枚举(请注意,这是在我的"{finish_to_start,finish_to_finish,start_to_start,start_to_finish}" 类中):

ActionRecord

我在运行insert查询之前调用以下方法(注意我设置了一个断点并确认在执行insert命令之前实际调用了它):

Public Enum ScheduleLinkType
    <EnumLabel("finish_to_start")>
    FinishToStart
    <EnumLabel("finish_to_finish")>
    FinishToFinish
    <EnumLabel("start_to_finish")>
    StartToFinish
    <EnumLabel("start_to_start")>
    StartToStart
End Enum

我尝试插入的字段参数是(来自Visual Studio调试器监视窗口):

NpgsqlConnection.RegisterEnumGlobally(Of ActionRecord.ScheduleLinkType)("schedule_link_type")

有人知道为什么这不起作用吗?

1 个答案:

答案 0 :(得分:0)

由于某种原因,这个问题已经消失了,现在一切正常了(请注意,自从发布原始问题后我已经将NPGSQL更新到3.1.8,但是由于升级或者我没有注意到这个问题是否已经消失我改变了别的东西。)