简体   繁体   English

.NET Core中的等效System.Data.Linq.Binary

[英]Equivalent System.Data.Linq.Binary in .net core

Can anyone help me for convert this code in .net core : 谁能帮助我在.net core中转换此代码:

    private static string GetValueFromModelValue(object formValue)
    {
        //Test to determine if its binary data. If it is, we need to convert it to a base64 string.
        Binary binaryValue = formValue as Binary;
        if (binaryValue != null)
        {
            formValue = binaryValue.ToArray();
        }

        //If the above conversion to an array worked, then the following will cast as a byte array and convert.
        byte[] byteArrayValue = formValue as byte[];
        if (byteArrayValue != null)
        {
            formValue = Convert.ToBase64String(byteArrayValue);
        }

        return formValue.ToString();
    }

The types in System.Data.Linq are not available in a version of .NET Core and .NET Standard (currently 1.0 - 2.0). System.Data.Linq中的类型在.NET Core和.NET Standard版本(当前为1.0-2.0)中不可用。

Since no caller can pass in a Binary object on .NET Core, you can either remove the code or put it inside a preprocessor define (this example assumes building for .NET Core 1.1): 由于没有调用者可以传递.NET Core上的Binary对象,因此您可以删除代码或将其放入预处理器定义中(此示例假定针对.NET Core 1.1进行构建):

#if !NETCOREAPP1_1
Binary binaryValue = …
if (binaryValue != null)
{
    …
}
#endif

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

相关问题 在 do.net 核心中使用 System.Data.Linq.Binary? - using System.Data.Linq.Binary in dotnet core? LINQ,聚合操作不支持“System.Data.Linq.Binary”类型 - The type 'System.Data.Linq.Binary' is not supported in aggregation operations - LINQ 将System.Drawing.Image转换为System.Data.Linq.Binary - Converting System.Drawing.Image to System.Data.Linq.Binary 如何将'byte []'类型转换为'System.Data.Linq.Binary' - How to convert type 'byte[]' to 'System.Data.Linq.Binary' 类型“ System.Data.Linq.Binary”在未引用的程序集中定义 - Type 'System.Data.Linq.Binary' is defined in an assembly that is not referenced 如何将内存流转换为System.Data.Linq.Binary? - How to convert Memory Stream to System.Data.Linq.Binary? 如何在C#中将System.Data.Linq.Binary分配为null? - How to assign System.Data.Linq.Binary to null in C#? 无法从“ System.DateTime”转换为“ System.Data.Linq.Binary”错误 - Cannot convert from 'System.DateTime' to 'System.Data.Linq.Binary' error 将SQL Server ROWVERSION放入System.Data.Linq.Binary属性时,出现System.InvalidCastException - System.InvalidCastException when getting SQL Server ROWVERSION into System.Data.Linq.Binary property 无法在LINQ中将类型'string'隐式转换为'System.Data.Linq.Binary - Cannot implicitly convert type 'string' to 'System.Data.Linq.Binary in LINQ to SQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM