简体   繁体   English

使用Dapper无法获取Long类型的数据

[英]Unable to get Long type of data using Dapper

The problem: I am unable to retrieve a column of type Long in an Oracle DB source and set it to a string property in a class in .Net 问题:我无法在Oracle DB源代码中检索类型为Long的列并将其设置为.Net中类的字符串属性

Details: While trying to use dapper to fire SQL queries and get back results, I came across a rather weird situation. 详细信息:在尝试使用dapper触发SQL查询并获取结果时,我遇到了一个很奇怪的情况。 I cannot share the actual class details, but here is a sample. 我无法分享实际的课程详细信息,但这是一个示例。 I have a class: 我有一堂课:

public class MyClass
{
    public string VeryLongMessage { get; set; }
}

I fire a dapper query as shown below: 我触发一个精简查询,如下所示:

using (var con = ConnectionUtility.GetConnection("MyConnectionString"))
{
    var result = con.QueryAsync<MyClass>("SELECT VeryLongMessage FROM MyView");
}

But when I check the value in result, I get a null value inside result's VeryLongMessage property. 但是当我检查结果中的值时,我在结果的VeryLongMessage属性中得到一个空值。

Has anyone else seen such an issue? 还有其他人看到过这样的问题吗? Any thoughts or suggestions? 有什么想法或建议吗?

Things I have verified: The column name of my dapper query and the property both match. 我已验证的内容: dapper查询的列名和属性都匹配。 the property type is string and column in Oracle db's view is Long. 属性类型是字符串,Oracle数据库视图中的列是Long。

Let me know in case you need more details. 如果您需要更多详细信息,请告诉我。

Look at dapper issue 173 看看dapper问题173

Unfortunately, it seems there are four indirect ways: 不幸的是,似乎有四种间接方法:

  • fix database (in your case you cannot) 修复数据库(您无法修复)

  • add additional stored finction to fetch LONG as CLOB. 添加其他存储的函数以将LONG作为CLOB获取。 Read Long to Varchar2 conversion.. and find similar topics on AskTom 阅读Long到Varchar2的转换..并在AskTom上找到类似的主题

  • fix the dapper :) 修复dapper :)

  • use ADO.NET instead 改用ADO.NET

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# Web API 使用 Dapper 使用存储过程插入数据 - 无法获得插入的记录 ID - C# Web API using Dapper to insert data using a stored procedure - unable to get inserted record Id Dapper无法将类型为“ Dapper.WrappedReader”的对象转换为类型为“ System.Data.SqlClient.SqlDataReader”的对象 - Dapper Unable to cast object of type 'Dapper.WrappedReader' to type 'System.Data.SqlClient.SqlDataReader' 在 dapper 中使用泛型类型获取所有存储过程 output 参数 - Get all stored procedure output parameters using generic type in dapper Postgres JSONB 数据类型映射使用 C# 和 Dapper - Postgres JSONB Data Type Mapping using C# and Dapper 使用Dapper将两个DB列映射到一种数据类型 - Map two DB column to one data type using Dapper 如何从SQLite数据库的新记录中获取具有char数据类型的字段,该字段也由触发器使用dapper + c#生成 - How to get field with char data type from new records of SQLite database, and its also generated by triggers using dapper + c# 尝试使用dapper使UPSERT处理一组数据 - Trying to get an UPSERT working on a set of data using dapper 如何使用Dapper从SQL Server获取bigint到long对象属性? - How to get a bigint to a long object property from SQL Server using Dapper? Dapper无法将“Microsoft.SqlServer.Types.SqlGeography”类型的对象强制转换为“System.Data.Entity.Spatial.DbGeography” - Dapper unable to cast object of type 'Microsoft.SqlServer.Types.SqlGeography' to type 'System.Data.Entity.Spatial.DbGeography' Dapper 返回数据类型 DATE 和时间 - Dapper return data type DATE with time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM