forked from ServiceStack/ServiceStack.OrmLite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileStreamTests.cs
More file actions
105 lines (82 loc) · 2.93 KB
/
Copy pathFileStreamTests.cs
File metadata and controls
105 lines (82 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using Microsoft.SqlServer.Types;
using NUnit.Framework;
using ServiceStack.DataAnnotations;
namespace ServiceStack.OrmLite.SqlServerTests.TableOptions
{
[TestFixture]
public class FileTableAttributeTests : SqlServer2012TableOptionsOrmLiteTestBase
{
[Explicit("Requires FileGroups enabled in DB")]
[Test]
public void Can_select_from_FileTable()
{
Db.DropAndCreateTable<FileTable>();
var ft = new FileTable
{
Name = "content.txt",
Path = SqlHierarchyId.Parse("/1/"),
FileContent = "contents".ToUtf8Bytes(),
FileType = MimeTypes.PlainText
};
Db.Insert(ft);
var fileTable = Db.Single<FileTable>(x => x.Name == "content.txt");
Assert.IsNotNull(fileTable);
Assert.IsTrue(ft.FileContent.EquivalentTo(fileTable.FileContent));
}
}
public class FileWithCustomSelect : FileTable
{
[CustomSelect("Contents.GetFileNamespacePath() + (CASE WHEN is_directory = 1 THEN '\' ELSE '' END)")]
public string FullPath { get; set; }
}
[SqlServerFileTable(directory: "FILESTREAM_DIR")]
public class FileTable
{
[PrimaryKey]
[CustomField("uniqueidentifier ROWGUIDCOL NOT NULL")]
[Default("newuid()")]
[Alias("stream_id")]
public Guid Id { get; set; }
[CustomField("varbinary(max) FILESTREAM")]
[Alias("file_stream")]
//[DataAnnotations.Ignore]
public byte[] FileContent { get; set; }
[Alias("name")]
[StringLength(255)]
public string Name { get; set; }
[Alias("path_locator")]
public SqlHierarchyId Path { get; set; }
//[ForeignKey(typeof(FileStream))]
[Alias("parent_path_locator")]
[Compute]
public SqlHierarchyId? ParentPath { get; set; }
[Alias("file_type")]
[Compute]
[StringLength(255)]
public string FileType { get; set; }
[Alias("cached_file_size")]
[Compute]
public long? FileSize { get; set; }
[Alias("creation_time")]
public DateTimeOffset CreationDateTime { get; set; }
[Alias("last_write_time")]
public DateTimeOffset LastWriteDateTime { get; set; }
[Alias("last_access_time")]
public DateTimeOffset? LastAccessDateTime { get; set; }
[Alias("is_directory")]
public bool IsDirectory { get; set; }
[Alias("is_offline")]
public bool IsOffline { get; set; }
[Alias("is_hidden")]
public bool IsHidden { get; set; }
[Alias("is_readonly")]
public bool IsReadOnly { get; set; }
[Alias("is_archive")]
public bool IsArchive { get; set; }
[Alias("is_system")]
public bool IsSystem { get; set; }
[Alias("is_temporary")]
public bool IsTemporary { get; set; }
}
}