Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 需要在查询时将存储在SQL Server中的(x,y)点作为二进制映像转换为浮点数组_C#_Sql Server_Tsql_Spotfire - Fatal编程技术网

C# 需要在查询时将存储在SQL Server中的(x,y)点作为二进制映像转换为浮点数组

C# 需要在查询时将存储在SQL Server中的(x,y)点作为二进制映像转换为浮点数组,c#,sql-server,tsql,spotfire,C#,Sql Server,Tsql,Spotfire,(位置、负载)点作为图像存储在SQL Server中。每次机器冲程时,都会创建一条记录来存储此位置/负载图以及其他数据 我需要将“图像”转换为数字进行分析。我计划在Spotfire中进行分析,这样任何Spotfire功能都可以在解决方案中使用 我有一个C#程序,可以从SQL查询数据并将其转换为CSV;但是,我希望有一种方法可以跳过此步骤,直接在Spotfire中查询要查看/分析的点 这个C#起作用,做我想做的事。我如何使用此(或某些变体)处理SQL查询中的数据,以便用户在打开Spotfire文件

(位置、负载)
点作为
图像存储在SQL Server中。每次机器冲程时,都会创建一条记录来存储此位置/负载图以及其他数据

我需要将“图像”转换为数字进行分析。我计划在Spotfire中进行分析,这样任何Spotfire功能都可以在解决方案中使用

我有一个C#程序,可以从SQL查询数据并将其转换为CSV;但是,我希望有一种方法可以跳过此步骤,直接在Spotfire中查询要查看/分析的点

这个C#起作用,做我想做的事。我如何使用此(或某些变体)处理SQL查询中的数据,以便用户在打开Spotfire文件之前不运行单独的“转换器”控制台应用程序

// Return a list of points from an array of bytes:
public static IList<PositionLoadPoint> GetPositionLoadPoints(byte[] bytes)
{
     IList<PositionLoadPoint> result = new List<PositionLoadPoint>();
     int midIndex = bytes.Length / 2;

     for (int i = 0; i < midIndex; i += 4)
     {
         byte[] load = new byte[4];
         byte[] position = new byte[4];

         Array.Copy(bytes, i, load, 0, 4);
         Array.Copy(bytes, midIndex + i, position, 0, 4);

         var point = new PositionLoadPoint(BitConverter.ToSingle(load, 0),
                                           BitConverter.ToSingle(position, 0));

        result.Add(point);
    }

    return result;
}
//从字节数组返回点列表:
公共静态IList GetPositionLoadPoints(字节[]字节)
{
IList结果=新列表();
int midIndex=字节。长度/2;
对于(int i=0;i
您可以使用运行该C代码并将二进制数据转换为结果集

CLR TVF有一个返回集合的“init”方法,然后SQL将为返回集合的每个成员运行“FillRow”方法。FillRow方法将对象转换为输出参数的“行”。例如:

using System;  
using System.Data.Sql;  
using Microsoft.SqlServer.Server;  
using System.Collections;  
using System.Data.SqlTypes;  
using System.Diagnostics;  

public class TabularEventLog  
{  
    [SqlFunction(FillRowMethodName = "FillRow")]  
    public static IEnumerable InitMethod(String logname)  
    {  
        return new EventLog(logname).Entries;    
    }  

    public static void FillRow(Object obj, out SqlDateTime timeWritten, out SqlChars message, out SqlChars category, out long instanceId)  
    {  
        EventLogEntry eventLogEntry = (EventLogEntry)obj;  
        timeWritten = new SqlDateTime(eventLogEntry.TimeWritten);  
        message = new SqlChars(eventLogEntry.Message);  
        category = new SqlChars(eventLogEntry.Category);  
        instanceId = eventLogEntry.InstanceId;  
    }  
}

SQL Server的未来版本中将删除
ntext
text
image
数据类型。避免在新的开发工作中使用这些数据类型,并计划修改当前使用它们的应用程序。改用
nvarchar(max)
varchar(max)
varbinary(max)
。首先,为什么要将此数据存储为
图像
?为什么不使用两个单独的列并删除所有的转换代码。一个旧的第三方软件控制数据库。我只是一个试图从中提取数据的工程师。但我很感谢各位的提醒。我已经咨询了我的IT专业人士,我们认为这会奏效。他将在下周实施。我现在就要标记为正确。我主要是一个潜伏者;感谢您的时间和社区。我在这里学到了很多。