使用 Entity Framework 4 创建 blob 属性?
我正在使用 WPF UI 创建 EF4 模型优先应用程序。我的 UI 上的控件之一是 RichTextDocument,它输出 WPF FlowDocument。我可以将 FlowDocument 序列化为字节数组,或者将其 XAML 标记提取为字符串。如果可以的话,我更愿意使用二进制序列化。以下是我的问题:
如果我序列化为字节数组,如何在 EDM 设计器中将实体属性指定为字节数组?
如果我提取 XAML 标记字符串,我可以指定 EDM 设计器将相应的数据库列创建为
nvarchar(max)
列吗?
至于第二个问题,我假设我总是可以手动编辑 MyModel.edmx.sql 文件,将数据类型从 nvarchar(4000)
更改为 nvarchar( max)
在执行之前,但我想知道是否可以在设计器中完成。
感谢您的帮助。
I am creating an EF4 model-first application with a WPF UI. One of the controls on my UI is a RichTextDocument, which outputs a WPF FlowDocument. I can either serialize the FlowDocument to a byte array, or extract its XAML markup as a string. I would prefer to use binary serialization, if I can. Here are my questions:
If I serialize to a byte array, how do I specify an entity property as a byte array in the EDM Designer?
If I extract a XAML markup string, can I specify that the EDM Designer create the corresponding database column as a
nvarchar(max)
column?
As to the second question, I assume I could always manually edit the MyModel.edmx.sql file to change the data type from nvarchar(4000)
to nvarchar(max)
before executing it, but I would like to know if it can be done in the Designer.
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
终于回到这个了。事实证明,如果它再明显一点,我就会被它绊倒。 EDM 具有
Binary
类型,可在实体类上创建byte[]
类型的属性。虽然 EDM 设计器中的类型通常与 CLR 类型名称匹配,但并非在所有情况下都是如此,如本问题所示。Finally got back to this one. Turns out that if it had been any more obvious, I'd have tripped over it. EDM has a
Binary
type that creates a property of typebyte[]
on an entity class. While the types in the EDM Designer generally match CLR type names, that's not true in all cases, as this issue shows.对于 nvarchar(max) 指定大小 |maxlength?|为 -1 值。正如 MSDN 文章之一所述,-1 大小值对应于 MAX sl 大小说明符,我记得......
For nvarchar(max) specify size |maxlength?| as -1 value. As it was described one of in MSDN articles, -1 size value corresponds to MAX sl size specifier, as i remember...