Dapper枚举映射 [英] Dapper enum mapping

查看:54
本文介绍了Dapper枚举映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助使用Dapper和Oracle映射枚举.

I need help for mapping enums with Dapper and Oracle.

我在Oracle类型NUMBER(1)中有一个字段,必须在我的实体中变成一个枚举.

I have a field in Oracle type NUMBER (1) and must turn into an enum in my entity.

public Status Status { get; set; }

状态是一个枚举:

public enum Status
{
    [Description("Inactive", "0")]
    Inactive = 0,

    [Description("Active", "1")]
    Active = 1,
 }

如何使用Dapper进行映射?

How to make the mapping using Dapper?

推荐答案

枚举应使用JustWork™来表示整数或字符串.如果它不起作用,则必须更详细地说明它引发的任何异常.例如,大声地思考和纯粹的推测,但是:IIRC Oracle有一个习惯,希望将大数设为64位,并且我想知道ebun映射代码是否可以处理所有形式的数字转换.如果没有,那就是一个错误.

Enums should JustWork™ for either integer or string representations. If it isn't working, you'll have to be more specific about any exception that it is throwing. For example, thinking aloud and pure speculation, but: IIRC Oracle has a habit of wanting to great numbers as 64-bit, and I wonder if the ebun mapping code handles all flavors of numeric conversion. If it doesn't, then that's a bug.

所以:这行得通吗?

这篇关于Dapper枚举映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆