Git Product home page Git Product logo

linqsharp's Introduction

LinqSharp

Other Language: 中文


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:

  • [no documentation yet, but have chinese version] Data annotations for table design
  • [no documentation yet, but have chinese version]] Data annotations for field standard
  • [no documentation yet] Function mapping
  • [no documentation yet] Column storage agent
  • [no documentation yet] Data calculation and audit

Supported version of Entity Framework:

  • Entity Framework Core 3.1
  • Entity Framework Core 2.1+

**Restricted supported version of Entity Framework: **

  • Entity Framework Core 3.0+ : 1 failed.

Install

You can install LinqSharp through NuGet

Package Manager

Install-Package LinqSharp
Install-Package LinqSharp.EFCore

.NET CLI

dotnet add package LinqSharp
dotnet add package LinqSharp.EFCore

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

Install-Package Northwnd
dotnet add package Northwnd

Then, you can 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.ToSql();
}

The variable sql is:

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

Function Provider Supports

.NET Function Jet MySql Oracle PostgreSQL Sqlite SqlServer
DbFunc.Random ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
DbFunc.Concat ✔️ ✔️ ✔️ ✔️
DbFunc.DateTime ✔️ 🔘 🔘 ✔️

For example, EntityFramework can not translate this expression:

.Where(x => new DateTime(x.Year, x.Month, x.Day) > DateTime.Now);

So, we provide another function to support this:

.Where(x => DbFunc.DateTime(x.Year, x.Month, x.Day) > DateTime.Now);

If use MySQL, the generated SQL is:

WHERE STR_TO_DATE(CONCAT(`x`.`Year`, '-', `x`.`Month`, '-', `x`.`Day`), '%Y-%m-%d') > CURRENT_TIMESTAMP();

linqsharp's People

Contributors

zmjack avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.