如何将(FluorineFX)ByteArray类型映射到EntityFramework中的byte [] [英] How to map the (FluorineFX)ByteArray type to byte[] in EntityFramework

查看:134
本文介绍了如何将(FluorineFX)ByteArray类型映射到EntityFramework中的byte []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在新项目中,我必须使用Flex客户端。该客户端从ASP.NET网站获取数据并将数据保存到ASP.NET网站。



对于这两个物理分离层之间的通信使用FluorineFX。该通信工作正常(从ASP.NET -Fluorine服务)。



所以下一步是写入或读取(SQLServerCE)DBMS。我被卡住了:
该服务获取一些对象(工作正常),并尝试将它们存储到商店。我的问题是如何将FluorineFX的 ByteArray DataType直接转换为一种EntityFramework (可能是byte [])。



我想实现以下内容:例如从客户端获取对象(使用POCO)直接持久存在。



是否可以生成以下(代码第一个POCO)类,并直接持续这个类?

  public class Photo 
{
public string GUID {get; set;}
public string标题{get; set;}
public ByteArray Thumbnail {get ; set;}
public ByteArray图片{get; set;}
}

这可能通过扩展EntityFramework?或者以其他方式?



提前感谢

解决方案

  public static ByteArray BytesToByteArray(byte [] bytes)
{
var ms1 = new MemoryStream(bytes);
返回新的ByteArray(ms1);
}

public static byte [] ByteArrayToBytes(ByteArray byteArray)
{
uint length = byteArray.Length;
byte [] bytes = new byte [length];
byteArray.ReadBytes(bytes,0,length);
返回字节;
}

检查是否有帮助


In a new project i have to use a Flex client. This client gets data from and saves data to a ASP.NET Website.

For the communication between these two physical separated layers FluorineFX is used. The communication works fine (to or from the ASP.NET-Fluorine Service).

So the next step is to write to or read from the (SQLServerCE)DBMS. I 'm stuck with this: the service gets some objects (works fine) and tries to persist these to the store. My problem is how to translate the ByteArray DataType of FluorineFX directly to a type of EntityFramework (may be byte[]).

I want to achieve the following: for example get the objects from the client and (using POCOs) persist directly.

So would it be possible to generate the following (code first POCO) class and also persisting this class directly?

public class Photo
{
public string   GUID {get;set;}
public string   Title                 {get;set;} 
public ByteArray   Thumbnail             {get;set;}
public ByteArray   Picture               {get;set;} 
}

Is this possible through an extension to EntityFramework? or somehow else?

Thanks in advance

解决方案

public static ByteArray BytesToByteArray(byte[] bytes)
    {
        var ms1 = new MemoryStream(bytes);
        return new ByteArray(ms1);
    }

    public static byte[] ByteArrayToBytes(ByteArray byteArray)
    {
        uint length = byteArray.Length;
        byte[] bytes = new byte[length];
        byteArray.ReadBytes(bytes, 0, length);
        return bytes;
    }

Check if this helps

这篇关于如何将(FluorineFX)ByteArray类型映射到EntityFramework中的byte []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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