Skip to content

Commit

Permalink
Release/0.8.3 (#272)
Browse files Browse the repository at this point in the history
* Require providing type (generically) when using the alias as a field in a select clause, general aliasing fixes (#265) (#269)
* Moved Execute and ExecuteAsync extension methods to interfaces and implementations in those classes implementing the interfaces. (#267)
* Added EXPERIMENTAL batching, enabling a set of queries to execute with a single Execute/ExecuteAsync. (#268)
* Deprecated query expression parameter from statement executor factory method(s). (#270)

Co-authored-by: Jerrod Eiman <jerrod.eiman@hattricklabs.com>
  • Loading branch information
gwgrubbs and JRod-Eiman committed Sep 9, 2021
1 parent 1229880 commit 5eb2986
Show file tree
Hide file tree
Showing 471 changed files with 9,889 additions and 5,722 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<Project>
<PropertyGroup>
<VersionPrefix>0.8.2</VersionPrefix>
<VersionPrefix>0.8.3</VersionPrefix>
<PackageIcon>images/htl-nuget-logo.png</PackageIcon>
<PackageReleaseNotes>See release notes at https://github.com/HatTrickLabs/dbExpression/releases/tag/v0.8.2</PackageReleaseNotes>
<PackageReleaseNotes>See release notes at https://github.com/HatTrickLabs/dbExpression/releases/tag/v0.8.3</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<None Include="../../build/htl-nuget-logo.png" Pack="true" Visible="false" PackagePath="images/htl-nuget-logo.png" />
Expand Down
22 changes: 20 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
# Changelog

## [0.8.2] - 2021-09-2
## [0.8.3] - 2021-09-09

### Added

### Changed
- Moved Execute and ExecuteAsync methods from extension methods to interfaces (and instance implementations)

### Fixed
- Fixed issue #265

### Breaking Changes
- A TOOLS UPDATE IS REQUIRED as code scaffolding templates were changed in support of interface changes
- Selecting aliased fields requires the use of the generic version of dbex.Alias method
- SQL Statement executor factory no longer accepts the QueryExpression as a parameter for creating an executor


## [0.8.2] - 2021-09-02

### Added
- Added OnBeforeUpdateSqlStatementAssembly event to allow global changes to update sql statements prior to assembly
- Added OnBeforeInsertSqlStatementAssembly event to allow global changes to insert sql statements prior to assembly

### Changed
- Improved paging implementation on server side blazor app

### Fixed
- Fixed issue #252
- Fixed issue #259
- Fixed issue #261
- Improved paging implementation on server side blazor app

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void IRuntimeSqlDatabase.UseConfigurationFactory(IRuntimeSqlDatabaseConfiguratio
/// <returns><see cref="SelectEntity{TEntity}"/>, a fluent builder for constructing a sql SELECT query expression for a <typeparamref name="TEntity"/> entity.</returns>
/// <typeparam name="TEntity">The entity type to select.</typeparam>
public static SelectEntity<TEntity> SelectOne<TEntity>()
where TEntity : class, IDbEntity
where TEntity : class, IDbEntity, new()
=> expressionBuilderFactory.CreateSelectEntityBuilder<TEntity>(configuration);

/// <summary>
Expand All @@ -73,7 +73,7 @@ public static SelectEntity<TEntity> SelectOne<TEntity>()
/// <see href="https://docs.microsoft.com/en-US/sql/t-sql/queries/select-transact-sql">Microsoft docs on SELECT</see>
/// </para>
/// </summary>
/// <param name="element">An expression of type <see cref="Sql.EnumElement{TEnum}" />
/// <param name="element">An expression of type <see cref="EnumElement{TEnum}" />
///, for example "dbo.AccessAuditLog.AccessResult"
/// </param>
/// <returns><see cref="Sql.SelectValue{TEnum}"/>, a fluent builder for constructing a sql SELECT query expression for a <typeparamref name="TEntity"/> entity.</returns>
Expand Down Expand Up @@ -511,7 +511,7 @@ public static SelectDynamic SelectOne(IEnumerable<AnyElement> elements, params A
/// <returns><see cref="SelectEntities{TEntity}"/>, a fluent builder for constructing a sql SELECT query expression for a list of <typeparamref name="TEntity"/> entities.</returns>
/// <typeparam name="TEntity">The entity type to select.</typeparam>
public static SelectEntities<TEntity> SelectMany<TEntity>()
where TEntity : class, IDbEntity
where TEntity : class, IDbEntity, new()
=> expressionBuilderFactory.CreateSelectEntitiesBuilder<TEntity>(configuration);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public object SelectPersonTotalPurchaseToCreditLimitReport()
var rpt = db.SelectMany(
dbo.Person.Id.As("PersonId"),
db.fx.Concat(dbo.Person.LastName, ", ", dbo.Person.FirstName).As("FullName"),
db.fx.IsNull(dbex.Alias("t0", "TotalPurchaseAmount"), 0).As("TotalPurchaseAmount"),
db.fx.IsNull(dbex.Alias<decimal>("t0", "TotalPurchaseAmount"), 0).As("TotalPurchaseAmount"),
dbo.Person.YearOfLastCreditLimitReview,
dbo.Person.CreditLimit
).From(dbo.Person)
Expand Down Expand Up @@ -85,8 +85,8 @@ public object SelectVIPByPurchaseCountAndYear(int purchaseCount, int year)

var vip = db.SelectMany(
dbo.Person.Id.As("PersonId"),
dbex.Alias("vips", "PurchaseCount"),
dbex.Alias("vips", "PurchaseYear"),
dbex.Alias<int>("vips", "PurchaseCount"),
dbex.Alias<int>("vips", "PurchaseYear"),
(dbo.Person.FirstName + " " + dbo.Person.LastName).As("FullName"))
.From(dbo.Person)
.InnerJoin(
Expand All @@ -101,7 +101,7 @@ public object SelectVIPByPurchaseCountAndYear(int purchaseCount, int year)
db.fx.Count(dbo.Purchase.Id) >= purchaseCount
& db.fx.DatePart(DateParts.Year, dbo.Purchase.PurchaseDate) == year)
).As("vips")
.On(dbo.Person.Id == dbex.Alias("vips", "PersonId"))
.On(dbo.Person.Id == ("vips", "PersonId"))
.OrderBy(dbo.Person.Id.Asc, dbex.Alias("vips", "PurchaseCount").Desc)
.Execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void IRuntimeSqlDatabase.UseConfigurationFactory(IRuntimeSqlDatabaseConfiguratio
/// <returns><see cref="SelectEntity{TEntity}"/>, a fluent builder for constructing a sql SELECT query expression for a <typeparamref name="TEntity"/> entity.</returns>
/// <typeparam name="TEntity">The entity type to select.</typeparam>
public static SelectEntity<TEntity> SelectOne<TEntity>()
where TEntity : class, IDbEntity
where TEntity : class, IDbEntity, new()
=> expressionBuilderFactory.CreateSelectEntityBuilder<TEntity>(configuration);

/// <summary>
Expand All @@ -73,7 +73,7 @@ public static SelectEntity<TEntity> SelectOne<TEntity>()
/// <see href="https://docs.microsoft.com/en-US/sql/t-sql/queries/select-transact-sql">Microsoft docs on SELECT</see>
/// </para>
/// </summary>
/// <param name="element">An expression of type <see cref="Sql.EnumElement{TEnum}" />
/// <param name="element">An expression of type <see cref="EnumElement{TEnum}" />
///, for example "dbo.Person.GenderType"
/// </param>
/// <returns><see cref="Sql.SelectValue{TEnum}"/>, a fluent builder for constructing a sql SELECT query expression for a <typeparamref name="TEntity"/> entity.</returns>
Expand Down Expand Up @@ -511,7 +511,7 @@ public static SelectDynamic SelectOne(IEnumerable<AnyElement> elements, params A
/// <returns><see cref="SelectEntities{TEntity}"/>, a fluent builder for constructing a sql SELECT query expression for a list of <typeparamref name="TEntity"/> entities.</returns>
/// <typeparam name="TEntity">The entity type to select.</typeparam>
public static SelectEntities<TEntity> SelectMany<TEntity>()
where TEntity : class, IDbEntity
where TEntity : class, IDbEntity, new()
=> expressionBuilderFactory.CreateSelectEntitiesBuilder<TEntity>(configuration);

/// <summary>
Expand Down
31 changes: 15 additions & 16 deletions samples/mssql/ServerSideBlazorApp/Service/CustomerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ static AddressModel mapAddress(AddressType addressType, ISqlFieldReader sqlRow)
var mailingAddress = nameof(CustomerDetailModel.MailingAddress);
var billingAddress = nameof(CustomerDetailModel.BillingAddress);
var shippingAddress = nameof(CustomerDetailModel.ShippingAddress);
Func<string,AnyElement,ObjectElement> alias = (string table, AnyElement a) => dbex.Alias(table, nameof(a));

var customer = new CustomerDetailModel();

Expand All @@ -149,21 +148,21 @@ static AddressModel mapAddress(AddressType addressType, ISqlFieldReader sqlRow)
dbo.Customer.YearOfLastCreditLimitReview,
dbo.Customer.BirthDate,
currentAgeApproximation.As(nameof(CustomerSummaryModel.CurrentAge)),
dbex.Alias(mailingAddress, nameof(AddressModel.Line1)),
dbex.Alias(mailingAddress, nameof(AddressModel.Line2)),
dbex.Alias(mailingAddress, nameof(AddressModel.City)),
dbex.Alias(mailingAddress, nameof(AddressModel.State)),
dbex.Alias(mailingAddress, nameof(AddressModel.ZIP)),
dbex.Alias(billingAddress, nameof(AddressModel.Line1)),
dbex.Alias(billingAddress, nameof(AddressModel.Line2)),
dbex.Alias(billingAddress, nameof(AddressModel.City)),
dbex.Alias(billingAddress, nameof(AddressModel.State)),
dbex.Alias(billingAddress, nameof(AddressModel.ZIP)),
dbex.Alias(shippingAddress, nameof(AddressModel.Line1)),
dbex.Alias(shippingAddress, nameof(AddressModel.Line2)),
dbex.Alias(shippingAddress, nameof(AddressModel.City)),
dbex.Alias(shippingAddress, nameof(AddressModel.State)),
dbex.Alias(shippingAddress, nameof(AddressModel.ZIP))
dbex.Alias<string>(mailingAddress, nameof(AddressModel.Line1)),
dbex.Alias<string>(mailingAddress, nameof(AddressModel.Line2)),
dbex.Alias<string>(mailingAddress, nameof(AddressModel.City)),
dbex.Alias<string>(mailingAddress, nameof(AddressModel.State)),
dbex.Alias<string>(mailingAddress, nameof(AddressModel.ZIP)),
dbex.Alias<string>(billingAddress, nameof(AddressModel.Line1)),
dbex.Alias<string>(billingAddress, nameof(AddressModel.Line2)),
dbex.Alias<string>(billingAddress, nameof(AddressModel.City)),
dbex.Alias<string>(billingAddress, nameof(AddressModel.State)),
dbex.Alias<string>(billingAddress, nameof(AddressModel.ZIP)),
dbex.Alias<string>(shippingAddress, nameof(AddressModel.Line1)),
dbex.Alias<string>(shippingAddress, nameof(AddressModel.Line2)),
dbex.Alias<string>(shippingAddress, nameof(AddressModel.City)),
dbex.Alias<string>(shippingAddress, nameof(AddressModel.State)),
dbex.Alias<string>(shippingAddress, nameof(AddressModel.ZIP))
)
.From(dbo.Customer)
.LeftJoin(dbo.PersonTotalPurchasesView).On(dbo.Customer.Id == dbo.PersonTotalPurchasesView.Id)
Expand Down
20 changes: 10 additions & 10 deletions samples/mssql/ServerSideBlazorApp/Service/OrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ public async Task<OrderDetailModel> GetOrderAsync(int orderId)
dbo.Purchase.PaymentMethodType,
dbo.Purchase.ExpectedDeliveryDate,
dbo.Purchase.TrackingIdentifier,
dbex.Alias(billingAddress, nameof(dbo.Address.Line1)),
dbex.Alias(billingAddress, nameof(dbo.Address.Line2)),
dbex.Alias(billingAddress, nameof(dbo.Address.City)),
dbex.Alias(billingAddress, nameof(dbo.Address.State)),
dbex.Alias(billingAddress, nameof(dbo.Address.Zip)),
dbex.Alias(shippingAddress, nameof(dbo.Address.Line1)),
dbex.Alias(shippingAddress, nameof(dbo.Address.Line2)),
dbex.Alias(shippingAddress, nameof(dbo.Address.City)),
dbex.Alias(shippingAddress, nameof(dbo.Address.State)),
dbex.Alias(shippingAddress, nameof(dbo.Address.Zip))
dbex.Alias<string>(billingAddress, nameof(dbo.Address.Line1)),
dbex.Alias<string>(billingAddress, nameof(dbo.Address.Line2)),
dbex.Alias<string>(billingAddress, nameof(dbo.Address.City)),
dbex.Alias<string>(billingAddress, nameof(dbo.Address.State)),
dbex.Alias<string>(billingAddress, nameof(dbo.Address.Zip)),
dbex.Alias<string>(shippingAddress, nameof(dbo.Address.Line1)),
dbex.Alias<string>(shippingAddress, nameof(dbo.Address.Line2)),
dbex.Alias<string>(shippingAddress, nameof(dbo.Address.City)),
dbex.Alias<string>(shippingAddress, nameof(dbo.Address.State)),
dbex.Alias<string>(shippingAddress, nameof(dbo.Address.Zip))
)
.From(dbo.Purchase)
.InnerJoin(dbo.Customer).On(dbo.Purchase.CustomerId == dbo.Customer.Id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ public static void AddMsSql2019Database<T>(this IDbExpressionConfigurationBuilde
typeof(RuntimeSqlDatabaseConfigurationFor<T>),
serviceProvider =>
{
var configBuilder = new RuntimeSqlDatabaseConfigurationBuilder(new RuntimeSqlDatabaseConfiguration());
builder.SchemaMetadata.Use(builder.Environment.Metadata);
builder.QueryExpressions.Use(serviceProvider.GetService<IQueryExpressionFactory>());
Expand Down Expand Up @@ -366,6 +365,7 @@ public static void AddMsSql2019Database<T>(this IDbExpressionConfigurationBuilde
)
);


builder.Services.AddSingleton(serviceProvider =>
{
return new RuntimeSqlDatabaseConfigurationDependencyInjectionShim(
Expand Down
41 changes: 0 additions & 41 deletions src/HatTrick.DbEx.MsSql/Builder/MsSqlDeleteEntitiesBuilder.cs

This file was deleted.

This file was deleted.

0 comments on commit 5eb2986

Please sign in to comment.