Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging 4.0 back into main #520

Merged
merged 6 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: PR Check
on:

pull_request:
branches: [ main ]
branches: [ main, release/** ]
paths-ignore:
- '**.md'

Expand Down
28 changes: 12 additions & 16 deletions samples/YesSql.Bench/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,26 @@ static async Task MainAsync(string[] args)
.UseSqlServer(@"Data Source =.; Initial Catalog = yessql; Integrated Security = True")
.SetTablePrefix("Bench");

using (var connection = configuration.ConnectionFactory.CreateConnection())
await using (var connection = configuration.ConnectionFactory.CreateConnection())
{
await connection.OpenAsync();

using (var transaction = connection.BeginTransaction(configuration.IsolationLevel))
{
var builder = new SchemaBuilder(configuration, transaction);
await using var transaction = await connection.BeginTransactionAsync(configuration.IsolationLevel);
var builder = new SchemaBuilder(configuration, transaction);

builder.CreateMapIndexTable<UserByName>(c => c
.Column<string>("Name")
.Column<bool>("Adult")
.Column<int>("Age")
);
await builder.CreateMapIndexTableAsync<UserByName>(c => c
.Column<string>("Name")
.Column<bool>("Adult")
.Column<int>("Age")
);

transaction.Commit();
}
await transaction.CommitAsync();
}

var store = await StoreFactory.CreateAndInitializeAsync(configuration);
store.RegisterIndexes<UserIndexProvider>();

using (var session = store.CreateSession())
await using (var session = store.CreateSession())
{
var user = await session.Query<User>().FirstOrDefaultAsync();

Expand All @@ -51,13 +49,11 @@ static async Task MainAsync(string[] args)
Age = 1
};


session.Save(bill);

await session.SaveAsync(bill);
await session.SaveChangesAsync();
}

using (var session = store.CreateSession())
await using (var session = store.CreateSession())
{
var user = await session.Query<User, UserByName>().Where(x => x.Adult == true).FirstOrDefaultAsync();

Expand Down
33 changes: 16 additions & 17 deletions samples/YesSql.Samples.FullText/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,36 @@ public static async Task Main(string[] args)

var store = await StoreFactory.CreateAndInitializeAsync(configuration);

using (var connection = store.Configuration.ConnectionFactory.CreateConnection())
await using (var connection = store.Configuration.ConnectionFactory.CreateConnection())
{
connection.Open();
await connection.OpenAsync();

using (var transaction = connection.BeginTransaction(store.Configuration.IsolationLevel))
{
new SchemaBuilder(store.Configuration, transaction)
.CreateReduceIndexTable<ArticleByWord>(table => table
.Column<int>("Count")
.Column<string>("Word")
);
await using var transaction = await connection.BeginTransactionAsync(store.Configuration.IsolationLevel);
var builder = new SchemaBuilder(store.Configuration, transaction);

transaction.Commit();
}
await builder.CreateReduceIndexTableAsync<ArticleByWord>(table => table
.Column<int>("Count")
.Column<string>("Word")
);

await transaction.CommitAsync();
}

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

// creating articles
using (var session = store.CreateSession())
await using (var session = store.CreateSession())
{
session.Save(new Article { Content = "This is a green fox" });
session.Save(new Article { Content = "This is a yellow cat" });
session.Save(new Article { Content = "This is a pink elephant" });
session.Save(new Article { Content = "This is a green tiger" });
await session.SaveAsync(new Article { Content = "This is a green fox" });
await session.SaveAsync(new Article { Content = "This is a yellow cat" });
await session.SaveAsync(new Article { Content = "This is a pink elephant" });
await session.SaveAsync(new Article { Content = "This is a green tiger" });

await session.SaveChangesAsync();
}

using (var session = store.CreateSession())
await using (var session = store.CreateSession())
{
Console.WriteLine("Simple term: 'green'");
var simple = await session
Expand Down
39 changes: 19 additions & 20 deletions samples/YesSql.Samples.Hi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ static async Task MainAsync(string[] args)
.SetTablePrefix("Hi")
);

using (var connection = store.Configuration.ConnectionFactory.CreateConnection())
await using (var connection = store.Configuration.ConnectionFactory.CreateConnection())
{
connection.Open();
await connection.OpenAsync();

using (var transaction = connection.BeginTransaction(store.Configuration.IsolationLevel))
{
new SchemaBuilder(store.Configuration, transaction)
.CreateMapIndexTable<BlogPostByAuthor>(table => table
.Column<string>("Author")
)
.CreateReduceIndexTable<BlogPostByDay>(table => table
.Column<int>("Count")
.Column<int>("Day")
await using var transaction = await connection.BeginTransactionAsync(store.Configuration.IsolationLevel);
var builder = new SchemaBuilder(store.Configuration, transaction);

await builder.CreateMapIndexTableAsync<BlogPostByAuthor>(table => table
.Column<string>("Author")
);

transaction.Commit();
}
await builder.CreateReduceIndexTableAsync<BlogPostByDay>(table => table
.Column<int>("Count")
.Column<int>("Day")
);

await transaction.CommitAsync();
};

// register available indexes
Expand All @@ -55,22 +55,21 @@ static async Task MainAsync(string[] args)
};

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

await session.SaveAsync(post);
await session.SaveChangesAsync();
}

// loading a single blog post
using (var session = store.CreateSession())
await using (var session = store.CreateSession())
{
var p = await session.Query().For<BlogPost>().FirstOrDefaultAsync();
Console.WriteLine(p.Title); // > Hello YesSql
}

// loading blog posts by author
using (var session = store.CreateSession())
await using (var session = store.CreateSession())
{
var ps = await session.Query<BlogPost, BlogPostByAuthor>().Where(x => x.Author.StartsWith("B")).ListAsync();

Expand All @@ -81,7 +80,7 @@ static async Task MainAsync(string[] args)
}

// loading blog posts by day of publication
using (var session = store.CreateSession())
await using (var session = store.CreateSession())
{
var ps = await session.Query<BlogPost, BlogPostByDay>(x => x.Day == DateTime.UtcNow.ToString("yyyyMMdd")).ListAsync();

Expand All @@ -92,7 +91,7 @@ static async Task MainAsync(string[] args)
}

// counting blog posts by day
using (var session = store.CreateSession())
await using (var session = store.CreateSession())
{
var days = await session.QueryIndex<BlogPostByDay>().ListAsync();

Expand Down
Loading
Loading