How to use Castle ActiveRecord with SQL Server 2008 FILESTREAM

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

I configured and enabled FILESTREAM in SQL Server 2008 without any problems.

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

Is there a property attribute that I must add in order to tell the activerecord of the lock 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 it enough to use the FILESTREAM function from SQL SERVER? I have not found many examples of using Castle ActiveRecord (NHibernate) with FILESTREAM.

Thank!

. , . , , , NTFS, SQL Server 2005 FileStream.

PictureData :

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

Edit

, Castle ActiveRecord PictureData varbinary(max), VARBINARY(MAX) FILESTREAM

Castle ActiveRecord ?

+3
1

, .

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; }

. !

+3

Source: https://habr.com/ru/post/1788654/


All Articles