File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using System . IO ;
3+ using Xunit ;
4+
5+ namespace LiteDB . Tests . Issues ;
6+
7+ public class Issue2506_Tests
8+ {
9+ [ Fact ]
10+ public void Test ( )
11+ {
12+ // Open database connection
13+ using LiteDatabase dataBase = new ( "demo.db" ) ;
14+
15+ // Get the file metadata/chunks storage
16+ ILiteStorage < string > fileStorage = dataBase . GetStorage < string > ( "myFiles" , "myChunks" ) ;
17+
18+ // Upload empty test file to file storage
19+ using MemoryStream emptyStream = new ( ) ;
20+ fileStorage . Upload ( "photos/2014/picture-01.jpg" , "picture-01.jpg" , emptyStream ) ;
21+
22+ // Find file reference by its ID (returns null if not found)
23+ LiteFileInfo < string > file = fileStorage . FindById ( "photos/2014/picture-01.jpg" ) ;
24+ Assert . NotNull ( file ) ;
25+
26+ // Load and save file bytes to hard drive
27+ file . SaveAs ( Path . Combine ( Path . GetTempPath ( ) , "new-picture.jpg" ) ) ;
28+
29+ // Find all files matching pattern
30+ IEnumerable < LiteFileInfo < string > > files = fileStorage . Find ( "_id LIKE 'photos/2014/%'" ) ;
31+ Assert . Single ( files ) ;
32+ // Find all files matching pattern using parameters
33+ IEnumerable < LiteFileInfo < string > > files2 = fileStorage . Find ( "_id LIKE @0" , "photos/2014/%" ) ;
34+ Assert . Single ( files2 ) ;
35+ }
36+ }
Original file line number Diff line number Diff line change 2929 </ItemGroup >
3030
3131 <ItemGroup >
32- <PackageReference Include =" FluentAssertions" Version =" 6.12.1 " />
33- <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.11.1 " />
32+ <PackageReference Include =" FluentAssertions" Version =" 6.12.2 " />
33+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.12.0 " />
3434 <PackageReference Include =" xunit" Version =" 2.9.2" />
3535 <PackageReference Include =" xunit.runner.console" Version =" 2.9.2" >
3636 <PrivateAssets >all</PrivateAssets >
You can’t perform that action at this time.
0 commit comments