Skip to content

Commit

Permalink
Release/0.8.2 (#263)
Browse files Browse the repository at this point in the history
* Resolved issue #252 by adding Like function to all relevant string based functions. (#253)

* General UI fixes to sample server side blazor app (#254)

* Fixed name override bug in stored procedure expression code gen templates

* Added OnBeforeUpdateSqlStatement assembly event. (#256)

* Added OnBeforeInsertAssemblyQueryExecutionEvent (#257)

* Changed insert assembler injected name for ordinal so as not to interfere with actual table columns named 'Ordinal' (#260)

* Gracefully exit execution on inserts with empty lists (#262)

Co-authored-by: Jerrod Eiman <jerrod.eiman@hattricklabs.com>
  • Loading branch information
gwgrubbs and JRod-Eiman committed Sep 2, 2021
1 parent d717cf4 commit 1229880
Show file tree
Hide file tree
Showing 92 changed files with 2,601 additions and 295 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.1</VersionPrefix>
<VersionPrefix>0.8.2</VersionPrefix>
<PackageIcon>images/htl-nuget-logo.png</PackageIcon>
<PackageReleaseNotes>See release notes at https://github.com/HatTrickLabs/dbExpression/releases/tag/v0.8.1</PackageReleaseNotes>
<PackageReleaseNotes>See release notes at https://github.com/HatTrickLabs/dbExpression/releases/tag/v0.8.2</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<None Include="../../build/htl-nuget-logo.png" Pack="true" Visible="false" PackagePath="images/htl-nuget-logo.png" />
Expand Down
14 changes: 14 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [0.8.2] - 2021-09-2

### 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
- Fixed issue #252
- Fixed issue #259
- Fixed issue #261
- Improved paging implementation on server side blazor app

### Breaking Changes

## [0.8.1] - 2021-06-23

### Added
Expand Down
27 changes: 0 additions & 27 deletions samples/mssql/ServerSideBlazorApp/GlobalProgressBar.cs

This file was deleted.

26 changes: 0 additions & 26 deletions samples/mssql/ServerSideBlazorApp/Models/PageResponseModel{T}.cs

This file was deleted.

44 changes: 44 additions & 0 deletions samples/mssql/ServerSideBlazorApp/Models/Page{T,U}.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Collections.Generic;
using System.Linq;

namespace ServerSideBlazorApp.Models
{
public class Page<T,U>
where U : PagingParameters, new()
{
public U PagingParameters { get; set; }
public IList<T> Data { get; set; } = new List<T>();
public int? TotalCount { get; set; }

public Page()
{
}

public Page(U parameters, IList<T> page, int totalCount)
{
PagingParameters = parameters;
Data = page;
TotalCount = totalCount;
}

public static Page<T,U> CreateDefault()
=> new(new U { Offset = 0, Limit = 10 }, new List<T>(), 0);
}

public class Page<T> : Page<T, PagingParameters>
{
public Page() { }

public Page(PagingParameters parameters, IList<T> page, int totalCount) : base(parameters, page, totalCount)
{
}

public new static Page<T> CreateDefault()
=> new Page<T>
{
PagingParameters = new PagingParameters { Offset = 0, Limit = 10 },
Data = new List<T>(),
TotalCount = 0
};
}
}
48 changes: 47 additions & 1 deletion samples/mssql/ServerSideBlazorApp/Models/PagingParameters.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Blazorise;
using HatTrick.DbEx.Sql.Expression;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ServerSideBlazorApp.Models
{
public class PagingParameters

public class PagingParameters : IEquatable<PagingParameters>
{
public int Offset { get; set; }
public int Limit { get; set; }
Expand Down Expand Up @@ -46,5 +48,49 @@ public static PagingParameters CreateDefault(Sort defaultSort)

public static Sort CreateDefaultSort(string defaultSortField, SortDirection defaultSortDirection)
=> new Sort(defaultSortField, defaultSortDirection == SortDirection.Ascending ? OrderExpressionDirection.ASC : OrderExpressionDirection.DESC);

public bool Equals(PagingParameters other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;

if (Offset != other.Offset) return false;
if (Limit != other.Limit) return false;
if (Sorting is null && other.Sorting is object) return false;
if (Sorting is object && other.Sorting is null) return false;
if (!Sorting.SequenceEqual(other.Sorting)) return false;

return true;
}

public override bool Equals(object other)
=> other is PagingParameters paging && Equals(paging);

public static bool operator ==(PagingParameters obj1, PagingParameters obj2)
{
if (obj1 is null && obj2 is object) return false;
if (obj1 is object && obj2 is null) return false;
if (obj1 is null && obj2 is null) return true;

return obj1.Equals(obj2);
}

public static bool operator !=(PagingParameters obj1, PagingParameters obj2)
=> !(obj1 == obj2);

public override int GetHashCode()
{
unchecked
{
const int @base = (int)2166136261;
const int multiplier = 16777619;

int hash = @base;
hash = (hash * multiplier) ^ Offset.GetHashCode();
hash = (hash * multiplier) ^ Limit.GetHashCode();
hash = (hash * multiplier) ^ (Sorting is object ? Sorting.GetHashCode() : 0);
return hash;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;

namespace ServerSideBlazorApp.Models
{
public class PagingParametersWithSearch : PagingParameters
{
public string SearchPhrase { get; set; }

public PagingParametersWithSearch()
{

}

public PagingParametersWithSearch(int offset, int limit, string searchPhrase) : base(offset, limit)
{
SearchPhrase = searchPhrase;
}

public PagingParametersWithSearch(int offset, int limit, Sort sort, string searchPhrase) : base(offset, limit, sort)
{
SearchPhrase = searchPhrase;
}

public PagingParametersWithSearch(int offset, int limit, IEnumerable<Sort> sorting, string searchPhrase) : base(offset, limit, sorting)
{
SearchPhrase = searchPhrase;
}

public new static PagingParametersWithSearch CreateDefault(Sort defaultSort)
=> new PagingParametersWithSearch(0, 10, defaultSort, null);
}
}
45 changes: 44 additions & 1 deletion samples/mssql/ServerSideBlazorApp/Models/Sort.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using HatTrick.DbEx.Sql.Expression;
using System;

namespace ServerSideBlazorApp.Models
{
public class Sort
public class Sort : IEquatable<Sort>
{
public string Field { get; set; }
public OrderExpressionDirection Direction { get; set; }
Expand All @@ -16,5 +17,47 @@ public Sort(string field, OrderExpressionDirection direction)
Field = field;
Direction = direction;
}

public bool Equals(Sort other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;

if (Field != other.Field) return false;
if (Direction != other.Direction) return false;

return true;
}

public override bool Equals(object other)
{
return other is Sort paging && Equals(paging);
}

public static bool operator ==(Sort obj1, Sort obj2)
{
if (obj1 is null && obj2 is object) return false;
if (obj1 is object && obj2 is null) return false;
if (obj1 is null && obj2 is null) return true;

return obj1.Equals(obj2);
}

public static bool operator !=(Sort obj1, Sort obj2)
=> !(obj1 == obj2);

public override int GetHashCode()
{
unchecked
{
const int @base = (int)2166136261;
const int multiplier = 16777619;

int hash = @base;
hash = (hash * multiplier) ^ Field?.GetHashCode() ?? 0;
hash = (hash * multiplier) ^ Direction.GetHashCode();
return hash;
}
}
}
}
10 changes: 3 additions & 7 deletions samples/mssql/ServerSideBlazorApp/Pages/Customer.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@page "/customers/{id}"
@inject GlobalProgressBar ProgressBar
@inject CustomerService CustomerService
@inject OrderService OrderService
@inject NavigationManager NavigationManager

<PageProgress Visible="@ShowProgressBar" />
<Breadcrumb>
<BreadcrumbItem>
<BreadcrumbLink To="@ReturnUrl"><i class="fas fa-chevron-left"></i>&nbsp;Back</BreadcrumbLink>
Expand All @@ -12,13 +12,13 @@

@if (Model is object)
{
<h3>
<Heading Size="HeadingSize.Is3">
@if (@Model.IsVIP)
{
<i class='fas fa-crown pr-2'></i>
}
@Model.FirstName @Model.LastName
</h3>
</Heading>
<Divider></Divider>

<Tabs SelectedTab="@SelectedTab" SelectedTabChanged="@OnSelectedTabChanged" Justified="true">
Expand Down Expand Up @@ -86,7 +86,3 @@
</Content>
</Tabs>
}

@code {

}
9 changes: 5 additions & 4 deletions samples/mssql/ServerSideBlazorApp/Pages/Customer.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace ServerSideBlazorApp.Pages
public partial class Customer
{
#region internals
private bool ShowProgressBar { get; set; } = false;
private string ReturnUrl { get; set; }
private CustomerDetailModel Model { get; set; }
private string SelectedTab { get; set; } = Tabs.Details.Id;
Expand Down Expand Up @@ -41,29 +42,29 @@ protected override async Task OnInitializedAsync()

private async Task<Page<OrderSummaryModel>> GetOrderSummaryPageAsync(PagingParameters pagingParameters)
{
await ProgressBar.Show();
ShowProgressBar = true;

try
{
return await OrderService.GetCustomerOrdersPageAsync(Model.Id, pagingParameters);
}
finally
{
await ProgressBar.Hide();
ShowProgressBar = false;
}
}

private async Task<OrderDetailModel> GetOrderDetailAsync(int orderId)
{
await ProgressBar.Show();
ShowProgressBar = true;

try
{
return await OrderService.GetOrderAsync(orderId);
}
finally
{
await ProgressBar.Hide();
ShowProgressBar = false;
}
}

Expand Down

0 comments on commit 1229880

Please sign in to comment.