Giter Site home page Giter Site logo

hguven / sqlexecutor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from feiniubus/sqlexecutor

0.0 2.0 0.0 115 KB

FeiniuBus Database Operating Competents.Offering DynamicQuery, Object Mapper, Linq Builder, Sql Builder and others.

License: MIT License

C# 100.00%

sqlexecutor's Introduction

SqlExecutor

FeiniuBus Database Operating Competents.Offering DynamicQuery, Object Mapper, Linq Builder, Sql Builder and others.

Support

Framework Support
netstandard2.0 +Support
netcoreapp2.0 +Support
golang +Client Only

Pipeline

Branch Status CI
master 2.0.0 Build status
milestone/2.0.0 RELEASED
milestone/2.1.0 PRE

Competents

Dynamic Query

Utility library for build data query descriptor or convert it to Linq Expression or SQL Statements. Here is a sample

DynamicQueryBuilder builder = DynamicQueryBuilder.Create(true);
var child1 = builder.ParamGroupBuilder.CreateChildAndGroup();
child1.ParamBuilder.Any("Extra", sub =>
{
    sub.ParamBuilder.Equal("Guest", "Andy");
});
var child2 = builder.ParamGroupBuilder.CreateChildOrGroup()
            .ParamBuilder
                .Contains("Address", "chengdu")
                .EndsWith("Address", "lnk")
                .Equal("Disabled", false)
                .GreaterThan("Amout", 10)
                .GreaterThanOrEqual("Price", 100)
                .In("Drink", "mileshake,coffee")
                .LessThan("Count", 10)
                .LessThanOrEqual("Total", 100)
                .StartsWith("Url", "Http://");
builder.OrderBy("Amout", ListSortDirection.Ascending)
    .Select("Guest").Take(10).Skip(10);
var dynamicQuery = builder.Build();

HashObject

HashObject,HashList

LinqBuilder

DynamicQuery-LinqExpression Converter.

SqlBuilder

STEP 1 : Add SqlBuilder Services in StartUp.cs

 public void ConfigureServices(IServiceCollection services)
{
   services.AddSQLBuilder(opts =>
   {
      opts.UseMySQL();
   });
}

STEP 2 : Builder mapping data with fluent style api

var mappings = new SqlFieldMappings();
mappings.Map("Guest", "t1.Guest")
        .Map("Address", "t1.Address")
        .Map("Disabled", "t1.Disabled")
        .Map("Amout", "t1.Amout")
        .Map("Price", "t1.Price")
        .Map("Drink", "t1.Drink")
        .Map("Count", "t1.Count")
        .Map("Total", "t1.Total");
// Native api also be supported
mappings.Add("Url", "t1.Url");

STEP 3 : Builder SQL clauses

// `selectBuilder` should be injected from DI. Notice it's lifetime and create service scope any time if	necessary.
selectBuilder.Mapping(mappings);
selectBuilder.Where(dynamicQuery.ParamGroup);
var whereClause = selectBuilder.BuildWhere();
var orderbyClause = selectBuilder.OrderBy(dynamicQuery.Order);

** In this case, value of whereClause is :

((Extra.Guest = @PARAM_0)) AND (t1.Address like @PARAM_1 OR t1.Address like @PARAM_2 OR t1.Disabled = @PARAM_3 OR t1.Amout > @PARAM_4 OR t1.Price >= @PARAM_5 OR t1.Drink IN (mileshake,coffee) OR t1.Count < @PARAM_6 OR t1.Total <= @PARAM_7 OR t1.Url like @PARAM_8)

SqlExecuter

An encapsulation layer of Ado.NET.

SqlExecuter.Mysql

An MySQL dialect implemention of SqlExecuter.

sqlexecutor's People

Contributors

ah-its-andy avatar gotoxu avatar

Watchers

James Cloos avatar Hayrullah GÜVEN 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.