如何将Castle ActiveRecord与SQL Server 2008 FILESTREAM功能一起使用(How to use Castle ActiveRecord with SQL Serv

编程入门 行业动态 更新时间:2024-10-27 02:23:22
如何将Castle ActiveRecord与SQL Server 2008 FILESTREAM功能一起使用(How to use Castle ActiveRecord with SQL Server 2008 FILESTREAM feature)

我想使用SQL SERVER 2008中的FILESTREAM功能将图像(C#)保存到数据库。

我已经在SQL Server 2008中配置并启用了FILESTREAM而没有任何问题。

如何使用SQL Server中的新功能通过Castle ActiveRecord将图像保存到数据库。

是否有一个属性属性,我必须添加,以告诉城堡activerecord使用FILESTREAM?

假设我有以下课程:

[ActiveRecord] public class Picture : ActiveRecordBase { [PrimaryKey] public int Id { get; set; } [Property] public byte[] PictureData { get; set; } }

这足以使用SQL SERVER中的FILESTREAM功能吗? 我没有找到使用Castle ActiveRecord(NHibernate)和FILESTREAM的例子。

谢谢!

编辑 :我不确定发生了什么。 看起来就像我做的那样,图像数据直接保存到数据库中,而不是使用SQL SERVER 2008 FileStream文档中提到的NTFS文件系统。

上面的PictureData属性现在看起来像这样:

[Property(SqlType = "VARBINARY(MAX)"] public byte[] PictureData { get; set; }

编辑

我发现Castle ActiveRecord创建了PictureData字段作为varbinary(max)类型,但它应该是VARBINARY(MAX) FILESTREAM

你如何告诉Castle ActiveRecord创建这样一个领域?

I would like to save images (C#) to the database by using the FILESTREAM feature from SQL SERVER 2008.

I've configured and enabled FILESTREAM in SQL Server 2008 without any problem.

How do I use this new feature from SQL Server through Castle ActiveRecord to save images to the database.

Is there a property attribute that I have to add in order to tell castle activerecord to use FILESTREAM ?

Suppose I have the following class:

[ActiveRecord] public class Picture : ActiveRecordBase { [PrimaryKey] public int Id { get; set; } [Property] public byte[] PictureData { get; set; } }

Is this sufficient to use the FILESTREAM feature from SQL SERVER? I haven't found much example using Castle ActiveRecord(NHibernate) with FILESTREAM.

Thanks!

Edit: I'm not sure what's going on. It seems like whatever I do, the image data is saved directly into the database instead of using the NTFS file system as mentionned in the SQL SERVER 2008 FileStream documentation.

The above PictureData property now looks like this:

[Property(SqlType = "VARBINARY(MAX)"] public byte[] PictureData { get; set; }

Edit:

I found out that Castle ActiveRecord creates the PictureData field as a varbinary(max) type but it should be VARBINARY(MAX) FILESTREAM

How do you tell Castle ActiveRecord to create such a field?

最满意答案

好吧,我找到了自己问题的答案。

这是您需要定义Castle ActiveRecord属性以启用FileStream的方法。

[Property(Unique = true, NotNull = true, SqlType = "UNIQUEIDENTIFIER ROWGUIDCOL", Default = "(newid())")] public Guid ImageGuid { get; set; } [Property(SqlType = "VARBINARY(MAX) FILESTREAM")] public byte[] ImageFile { get; set; }

这应该可以帮助一些人。 关于这个的信息不多!!

Well I found the answer to my own question.

This is how you need to define your Castle ActiveRecord properties to enable FileStream.

[Property(Unique = true, NotNull = true, SqlType = "UNIQUEIDENTIFIER ROWGUIDCOL", Default = "(newid())")] public Guid ImageGuid { get; set; } [Property(SqlType = "VARBINARY(MAX) FILESTREAM")] public byte[] ImageFile { get; set; }

This should help some people out there. Not many info about this!!

更多推荐

本文发布于:2023-08-08 00:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466726.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   功能   ActiveRecord   Castle   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!