Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions samples/YesSql.Bench/YesSql.Bench.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netcoreapp6.0</TargetFrameworks>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>YesSql.Bench</AssemblyName>
Expand Down
3 changes: 1 addition & 2 deletions samples/YesSql.Samples.FullText/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public static async Task Main(string[] args)
}

var configuration = new Configuration()
.UseSqLite($"Data Source={filename};Cache=Shared")
;
.UseSqLite($"Data Source={filename};Cache=Shared");

var store = await StoreFactory.CreateAndInitializeAsync(configuration);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netcoreapp6.0</TargetFrameworks>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>YesSql.Samples.FullText</AssemblyName>
Expand Down
9 changes: 9 additions & 0 deletions samples/YesSql.Samples.Hi/Indexes/BlogPostByTag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using YesSql.Indexes;

namespace YesSql.Samples.Hi.Indexes
{
public class BlogPostByTag : MapIndex
{
public string Tag { get; set; }
}
}
5 changes: 5 additions & 0 deletions samples/YesSql.Samples.Hi/Indexes/BlogPostIndexProvider.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using YesSql.Indexes;
using YesSql.Samples.Hi.Models;
Expand Down Expand Up @@ -37,6 +38,10 @@ public override void Describe(DescribeContext<BlogPost> context)
return index.Count > 0 ? index : null;
}
);

// for each BlogPost, create a BlogPostByTag index
context.For<BlogPostByTag>()
.Map(blogPost => blogPost.Tags.Select(tag => new BlogPostByTag { Tag = tag }));
}
}
}
94 changes: 72 additions & 22 deletions samples/YesSql.Samples.Hi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System;
using System.IO;
using System.Threading.Tasks;
using YesSql.Provider.SqlServer;
using YesSql.Provider.Sqlite;
using YesSql.Samples.Hi.Indexes;
using YesSql.Samples.Hi.Models;
using YesSql.Sql;
Expand All @@ -9,18 +10,18 @@ namespace YesSql.Samples.Hi
{
internal class Program
{
static void Main(string[] args)
public static async Task Main(string[] args)
{
MainAsync(args).GetAwaiter().GetResult();
}
var filename = "yessql.db";

static async Task MainAsync(string[] args)
{
var store = await StoreFactory.CreateAndInitializeAsync(
new Configuration()
.UseSqlServer(@"Data Source =.; Initial Catalog = yessql; Integrated Security = True")
.SetTablePrefix("Hi")
);
if (File.Exists(filename))
{
File.Delete(filename);
}

var configuration = new Configuration()
.UseSqLite($"Data Source={filename};Cache=Shared");
var store = await StoreFactory.CreateAndInitializeAsync(configuration);

using (var connection = store.Configuration.ConnectionFactory.CreateConnection())
{
Expand All @@ -35,29 +36,50 @@ static async Task MainAsync(string[] args)
.CreateReduceIndexTable<BlogPostByDay>(table => table
.Column<int>("Count")
.Column<int>("Day")
);
)
.CreateMapIndexTable<BlogPostByTag>(table => table
.Column<string>("Tag")
);

transaction.Commit();
}
};
}

// register available indexes
store.RegisterIndexes<BlogPostIndexProvider>();

// creating a blog post
var post = new BlogPost
var post1 = new BlogPost
{
Title = "Hello YesSql",
Author = "Bill",
Content = "Hello",
Content = "Hello Bill!",
PublishedUtc = DateTime.UtcNow,
Tags = new[] { "Hello", "YesSql" }
Tags = new[] { "Hello", "YesSql", "Test" }
};
var post2 = new BlogPost
{
Title = "Bye YesSql",
Author = "Bill",
Content = "Bye Bill!",
PublishedUtc = DateTime.UtcNow,
Tags = new[] { "Bye", "YesSql", "Test" }
};
var post3 = new BlogPost
{
Title = "Other blog title",
Author = "Lucian",
Content = "This is the content.",
PublishedUtc = DateTime.UtcNow,
Tags = new[] { "Other", "YesSql", "Test", "Blog" }
};

// saving the post to the database
using (var session = store.CreateSession())
{
session.Save(post);
session.Save(post1);
session.Save(post2);
session.Save(post3);

await session.SaveChangesAsync();
}
Expand All @@ -66,8 +88,9 @@ static async Task MainAsync(string[] args)
using (var session = store.CreateSession())
{
var p = await session.Query().For<BlogPost>().FirstOrDefaultAsync();
Console.WriteLine(p.Title); // > Hello YesSql
Console.WriteLine($"First blog: '{p.Title}'"); // > Hello YesSql
}
Console.WriteLine("");

// loading blog posts by author
using (var session = store.CreateSession())
Expand All @@ -76,9 +99,10 @@ static async Task MainAsync(string[] args)

foreach (var p in ps)
{
Console.WriteLine(p.Author); // > Bill
Console.WriteLine($"'{p.Title}' by {p.Author}"); // > Bill
}
}
Console.WriteLine("");

// loading blog posts by day of publication
using (var session = store.CreateSession())
Expand All @@ -87,9 +111,10 @@ static async Task MainAsync(string[] args)

foreach (var p in ps)
{
Console.WriteLine(p.PublishedUtc); // > [Now]
Console.WriteLine($"'{p.Title}' published on {p.PublishedUtc}"); // > [Now]
}
}
Console.WriteLine("");

// counting blog posts by day
using (var session = store.CreateSession())
Expand All @@ -98,9 +123,34 @@ static async Task MainAsync(string[] args)

foreach (var day in days)
{
Console.WriteLine(day.Day + ": " + day.Count); // > [Today]: 1
Console.WriteLine($"Blogs count on {day.Day}: {day.Count}"); // > [Today]: 1
}
}
Console.WriteLine("");

// load blog posts with tag "Hello"
using (var session = store.CreateSession())
{
var ps = await session.Query<BlogPost, BlogPostByTag>(x => x.Tag == "Hello").ListAsync();

foreach (var p in ps)
{
Console.WriteLine($"'{p.Title}' has 'Hello' tag. Tag list: " + string.Join(", ", p.Tags));
}
}
Console.WriteLine("");

// load blog posts with tag "Test"
using (var session = store.CreateSession())
{
var ps = await session.Query<BlogPost, BlogPostByTag>(x => x.Tag == "Test").ListAsync();

foreach (var p in ps)
{
Console.WriteLine($"'{p.Title}' has 'Test' tag. Tag list: " + string.Join(", ", p.Tags));
}
}
Console.WriteLine("");
}
}
}
9 changes: 6 additions & 3 deletions samples/YesSql.Samples.Hi/YesSql.Samples.Hi.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netcoreapp6.0</TargetFrameworks>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>YesSql.Samples.Hi</AssemblyName>
Expand All @@ -16,8 +16,11 @@
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\YesSql.Core\YesSql.Core.csproj" />
<ProjectReference Include="..\..\src\YesSql.Provider.SqlServer\YesSql.Provider.SqlServer.csproj" />
<ProjectReference Include="..\..\src\YesSql.Provider.Sqlite\YesSql.Provider.Sqlite.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<AssemblyName>YesSql.Samples.Performance</AssemblyName>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
Expand All @@ -11,7 +11,7 @@
<None Remove="Properties\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\YesSql.Core\YesSql.Core.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion samples/YesSql.Samples.Web/YesSql.Samples.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
13 changes: 10 additions & 3 deletions src/YesSql.Abstractions/YesSql.Abstractions.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
<PackageReference Include="System.Memory" Version="4.5.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>
<ItemGroup>
<!-- Latest minimum LTS version. We don't want to force a higher version to applications -->
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Remove="Microsoft.SourceLink.GitHub" />
</ItemGroup>
</Project>
9 changes: 8 additions & 1 deletion src/YesSql.Core/YesSql.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
<ItemGroup>
<PackageReference Include="Dapper.StrongName" Version="2.0.123" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
Expand All @@ -22,4 +26,7 @@
<ProjectReference Include="..\YesSql.Abstractions\YesSql.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<None Remove="Microsoft.SourceLink.GitHub" />
</ItemGroup>
</Project>
9 changes: 8 additions & 1 deletion src/YesSql.Provider.MySql/YesSql.Provider.MySql.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="MySqlConnector" Version="2.1.0" />
<PackageReference Include="MySqlConnector" Version="2.1.8" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\YesSql.Core\YesSql.Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="Microsoft.SourceLink.GitHub" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
<ProjectReference Include="..\YesSql.Core\YesSql.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="6.0.1" />
<PackageReference Include="Npgsql" Version="6.0.4" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Remove="Microsoft.SourceLink.GitHub" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
<ProjectReference Include="..\YesSql.Core\YesSql.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.1" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.1.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Remove="Microsoft.SourceLink.GitHub" />
</ItemGroup>
</Project>
11 changes: 10 additions & 1 deletion src/YesSql.Provider.Sqlite/YesSql.Provider.Sqlite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
<PackageReference Include="Microsoft.Data.Sqlite" Version="5.0.12" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.4" />
</ItemGroup>
<ItemGroup>
<None Remove="Microsoft.SourceLink.GitHub" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>