Skip to content

Latest commit

 

History

History
293 lines (189 loc) · 10.9 KB

README.md

File metadata and controls

293 lines (189 loc) · 10.9 KB

LinqSharp

LinqSharp is an open source LINQ extension library that allows you to write simple code to generate complex queries, including query extensions and dynamic query generation.

LinqSharp.EFCore is an enhanced library for EntityFramework, providing more data annotations, database functions, and custom storage rules, etc.


LinqSharp provides enhancements to LINQ in the following ways:

LinqSharp.EFCore provides enhancements to Entity Frameowk in the following ways:


Supported versions

Supported Out of support
.NET Static Badge Static Badge Static Badge Static Badge
.NET Standard Static Badge Static Badge
Entity Framework Core Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge

Install

You can install LinqSharp through NuGet

dotnet add package LinqSharp
dotnet add package LinqSharp.EFCore

Recent

Version 8.0.0

  • Update dependencies.

Version 7.0.45

  • Update search extension method.
  • Now, you can use the new syntax to search any field in a table or related tables.

Version 7.0.42

  • Enable nullable checking.
  • Compatibility updates: NStandard - 0.70.0 - Update.

Version 7.0.41 - EFCore

  • Enable nullable checking.
  • Fix some bugs.
  • Rename FieldOption to AutoMode.
  • Rename IFieldOptionScope to IAutoModeScope.

Version 7.0.37.17 - EFCore

  • Add new annotation RowLock to disable locked records from being changed or deleted.
  • Add new annotation AutoMonthOnly to format DateTime / DateTimeOffset / DateOnly only keeping the year and month.
  • Add these new extension methods to create intelligently tracked queries with specified behavior for DbContext.
    • BeginRowLock
    • BeginTimestamp
    • BeginUserTrace
  • Breaking Change: The length of Value in KeyValueEntity is set to 768 by default.
  • Breaking Change: Change some internal class names.

Version 7.0.37

  • Rename IExtraFieldFilter to IAdvancedFieldFilter.

Version 7.0.36

  • New Methods: Added Random() and RandomOrDefault() to get a random record.

  • Breaking Change: Columns marked by SpecialAutoAttribute cannot be modified manually, and their values can only be maintained by the engine.

    This change will work better with the Update method provided by EFCore.

Version 7.0.35

  • Experimental:

    Some methods in LinqSharp.EFCore that do not depend on EntityFramework have been extracted to LinqSharp.EFCore.

    Third-party libraries can use these methods more conveniently by referencing LinqSharp.EFCore.Core.

  • DirectQuery has been renamed to DirectQueryScope.

Version: 7.0.34

  • New Feature: Added IExtraFieldFilter interface for more flexible field filtering.

Version: 7.0.32

  • Compatibility updates: NStandard - 0.48.0 - Update, Ref.

Version: 7.0.30

  • Compatibility updates: NStandard - 0.45.0 - Update, DateOnlyType and DateTimeType.

Version: 7.0.27

  • Breaking Change: Adjusted some namespace names.
  • Bug fixed: Null support for AllSame.

Version: 7.0.24

  • Breaking Change: Adjusted some namespace names.

Version: 7.0.20

  • Indexing / UniqueIndexing modified to lazy query.

Version: 7.0.18.1

  • Two field filters have been added: DateOnlyRangeFilter, DateTimeRangeFilter.
  • These methods has been marked as obsolete, please use FilterBy(Func<,>, DateTimeRangeFilter) method instead:
    • WhereAfter
    • WhereBefore
    • WhereBetween

Version: 7.0.17

  • New Feature: Added FilterBy support for QueryHelper, IFieldFilter can now be applied directly to QueryHelper.

Version: 7.0.13

  • New Feature: Added IFieldFilter for building field-based conditions, support dynamic building.

Version: 7.0.11

  • New Feature: Added IFieldLocalFilter / IFieldQueryFilter for building field-based conditions.

Version: 7.0.10

  • New Feature: Added IEnumerableExtensions.Index for creating indexes to provide faster queries.

Version: 7.0.9

  • IQueryFilter no longer needs to implement local filter methods. Implement ILocalFilter if needed.
  • Filter extension now supports executing multiple filters sequentially.

Version: 7.0.2

  • Dynamic Query: QueryHelper provides property chain analysis to support dynamic query of Owned Entity.
  • Optimized GroupByCount performance (takes about -35% in time), but planned to remove this method.
  • Mark GroupByCount as Obsolete method, please use Chunk method instead.
    • EFCore 6.0 and above: Not provided, use the native method.
    • EFCore 5.0 and below: Code compatibility.

Version: 7.0

  • Provides two new data annotations:

  • [Breaking Change] QuickDataView has been removed, please use IEnumerableExtensions.FullJoin instead.

  • [Breaking Change] IEntity.AcceptBut has been removed.

  • [Breaking Change] Change the method name IQueryableExtensions.ToSql to ToQueryString.

    • EFCore 5.0 and above: Not provided, use the native method.
    • EFCore 3.1 and below: Code compatibility.

Version: 6.0.16

  • [Breaking Change] The Ensure methods have been removed, and AddOrUpdate methods are recommended to be used instead.
  • [Breaking Change] CustomDatabaseFacade has been removed.
  • Provide EntityMonitoringFacade for monitoring table CRUD to facilitate writing other docking operations.

Version: 6.0.14

  • Some methods in AutoAttribute has been changed:

    /*
    public abstract object Format(object entity, object value);
    */
    public abstract object Format(object entity, Type propertyType, object value);

Version: 6.0.6

  • Change the method name XWhere to Filter.
  • Allows to create a stand-alone filter IQueryFilter and query in the Filter method.

Version: 6.0.4

  • Simplify the code writing for Provider.

  • After 2.1.104 | 3.0.104 | 3.1.104 | 5.0.4 | 6.0.4 .

Old:

[Provider(typeof(JsonProvider<NameModel>))]
public NameModel NameModel { get; set; }

New:

[JsonProvider]
public NameModel NameModel { get; set; }

Version: 6.0

  • To avoid naming conflicts, IndexAttribute has been renamed to IndexFieldAttribute.

Try using the sample database

Northwnd, an early sample database shipped with SQL Server, describes a simple "enterprise sales network" scenario.

The database includes a network of employees, orders, and suppliers.


The NuGet version of Northwnd is a SQLite database (Code First).

Repository:https://github.com/zmjack/Northwnd


You can install Northwnd through NuGet

dotnet add package Northwnd

Try LinqSharp:

using (var context = NorthwndContext.UseSqliteResource())
{
    ...
}

For example:

using (var sqlite = NorthwndContext.UseSqliteResource())
{
    var query = sqlite.Shippers.Where(x => x.CompanyName == "Speedy Express");
    var sql = query.ToQueryString();
    Console.WriteLine(sql);
}

The variable sql is:

SELECT "x"."ShipperID", "x"."CompanyName", "x"."Phone"
FROM "Shippers" AS "x"
WHERE "x"."CompanyName" = 'Speedy Express';