EF 4.1 Pocos。文件流中的压力......需要建议 [英] EF 4.1 Pocos. Stress in Filestream ... Need Advice

查看:81
本文介绍了EF 4.1 Pocos。文件流中的压力......需要建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我从EF4.1和Pocos开始,我有几个问题:

I am starting with EF4.1 and Pocos and I have a few questions:

1 - 什么数据我应该在Poco中用于文件流列吗?

1 - What data type should I use in a Poco for a filestream column?

2 - 在最近的项目中,使用EF 4.0,我遇到了一些压力问题。

2 - In a recent project, using EF 4.0, I experienced a few stress issues.

    加载包含文件流列的记录时发生问题。

     The problem happened when loading records that contained Filestream columns.

    我需要对新类型使用投影,因此未加载二进制数据。

     I needed to use projection to new types so the binary data was not loaded.

     EF 4.1中针对此问题的最佳方法是什么?

     What is the best approach in EF 4.1 for this issues?

3 - 当加载多个记录时,我不需要二进制数据,但我需要知道它是否包含某些内容。

3 - When loading multiple records I don't need the binary data but I need to know if it contains something.

    我应该将列与null进行比较吗?这是一个好方法吗?

     Should I compare the column to null? Is this a good approach?

我希望我能对这些问题得到一些反馈,这样我就可以使用EF 4.1和Pocos做到这一点。

I hope I can get some feedback on these issues so I can do it right using EF 4.1 and Pocos.

谢谢,

Miguel

 

推荐答案

Hello,

Hello,

EF不支持文件流的流行为 - 它与varbinary(max)列一样使用filestream。此外,纯代码首先永远不会使用文件流创建数据库 - 如果要映射到文件流
列,则只能使用现有数据库的流畅API。

EF doesn't support streaming behavior of filestream - it works with filestream as with varbinary(max) column. Also pure code first will never create database with a filestream - you can only use fluent API with existing database if you want to map to filestream column.


  1. 使用字节数组:byte []
  2. EF 4.1也会出现同样的问题。要避免它,你必须使用之前使用的投影,或者你应该实现

    表拆分
    ,其中二进制数据将被放置到从主实体引用的独立实体。
  3. 在查询中进行任何测试后,您需要进行投影。如果您经常需要这样做,可以尝试在数据库中使用计算列并将列映射到您的实体。
  1. Use byte array: byte[]
  2. The same problem happens with EF 4.1. To avoid it you must either use projection as you used before or you should implement table splitting where binary data will be placed to separate entity referenced from the main entity.
  3. Once you do any test in the query you will need a projection. If you need to do this often you can try to use computed column in the database and map column to your entity.

最好的问候,

Ladislav

Best regards,
Ladislav


这篇关于EF 4.1 Pocos。文件流中的压力......需要建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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