gpt4 book ai didi

asp.net-mvc - 当我使用 asp.net mvc web api 读取 Oracle 表时出现严重错误(数据类型为 CLOB)

转载 作者:行者123 更新时间:2023-12-04 18:00:31 32 4
gpt4 key购买 nike

没有数据类型是 CLOB 我可以轻松读取 Oracle 表数据,但不幸的是,当某些表具有 CLOB 数据类型时,我确实遇到了一个严重的问题,我该怎么办。

错误信息

{"$id":"1","Message":"An error has occurred.","ExceptionMessage":"The 'ObjectContent1' type failed to serialize the response body for
content type 'application/json;
charset=utf-8'.","ExceptionType":"System.InvalidOperationException","StackTrace":null,"InnerException":{"$id":"2","$type":"System.Web.Http.HttpError,
System.Web.Http","Message":"An error has
occurred.","ExceptionMessage":"Exception of type
'System.OutOfMemoryException' was
thrown.","ExceptionType":"System.OutOfMemoryException","StackTrace":"
at System.String.Concat(String str0, String str1)\r\n at
OracleInternal.I18N.Conv.ConvertBytesToString(IList
1 bytes, Int32 bytesOffset, Int32 bytesCount, Char[] chars, Boolean bUseReplacementChar)\r\n at OracleInternal.I18N.Conv.ConvertBytesToString(IList1 bytes, Char[]
chars, Boolean bUseReplacementChar)\r\n at
OracleInternal.ServiceObjects.OracleClobImpl.GetCompleteClobData(Int32
currentRow, Int32 columnIndex, OracleConnectionImpl connImpl, Byte[]
lobLocator, DataUnmarshaller dataUnmarshaller, TTCLobAccessor
lobAccessor, OracleClobImpl& oraClobImpl)\r\n at
Oracle.ManagedDataAccess.Client.OracleDataReader.GetString(Int32
i)\r\n at lambda_method(Closure , Shaper )\r\n at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func
2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)\r\n at lambda_method(Closure , Shaper )\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Coordinator1.ReadNextElement(Shaper
shaper)\r\n at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper
1.SimpleEnumerator.MoveNext()\r\n at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at System.Web.Http.WebHost.HttpControllerHandler.d__1b.MoveNext()"}}

附言:环境
1. Visual Studio 2015
2. ASP.NET MVC WebApi( Entity Framework )
3.甲骨文11G
4.使用VS默认的Web API项目

最佳答案

"Exception of type 'System.OutOfMemoryException' was thrown."

我想您的 CLOB 对象太大而无法转换。它有多大?在程序执行期间检查您的可用内存。您有足够的空闲内存吗?

基于 this Oracle Community 上的回答看起来像是涉及 CLOB 时 .net 驱动程序中存在几个问题;我发现的一个建议是尝试将 CLOB 解析为通用 BLOB 并将其读取为 byte[]。你可以像这样将 byte[] 转换为字符串

string result = System.Text.Encoding.UTF8.GetString(byteArray);

关于asp.net-mvc - 当我使用 asp.net mvc web api 读取 Oracle 表时出现严重错误(数据类型为 CLOB),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36145613/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com