我想使用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!!
更多推荐
发布评论