SqlSharp 1.0.3

Dynamics sql query builder for known providers - Sql Server, Oracle, MySql.
     Use QueryHelper to see sql output. QueryHelper also has GetSelects() to generate Select query for all fields on a type/object.

Install-Package SqlSharp -Version 1.0.3
dotnet add package SqlSharp --version 1.0.3
<PackageReference Include="SqlSharp" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SqlSharp --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SqlSharp

Generate SqlQuery for your type/object dynamically.

  ============  Query builder example:   ===============

  using SqlSharp;
  using SqlSharp.Query;

  SharpQuery select = SharpQuery
        .Select()
        .Field("Id").As("AccountId") // with alias
        .Field("AccountNumber") //name only
        .Where("account.created", Compare.GreaterThanEqual, "'2018-01-01'") //where clause
        .TopN(100)
        .From("account"); //table
  

  // sql output
  var sqlQuery = QueryHelper.GetSqlOutput(select);


  ===========   Generate Select dynamically =============
  
  //Query With Alias:

  // Add a class, Define column name with optional attribute, property name is used as Alias
  
  public class Account
  {
  
         [SqlSharp("Account.Id")] // column name
         public string AccountId { get; set; } // alias

         public string AccountNumber { get; set; }

  }

  // generate query:

  Account a = new Account();
  
  var fields = QueryHelper.GetSelects(a);

    SharpQuery select = SharpQuery
            .Select()
            .Fields(fields.ToArray())
            .Where("account.created", Compare.GreaterThanEqual, "'2018-01-01'")
            .TopN(100)
            .From("account");


    var sqlOutput = QueryHelper.GetSqlOutput(select);

SqlSharp

Generate SqlQuery for your type/object dynamically.

  ============  Query builder example:   ===============

  using SqlSharp;
  using SqlSharp.Query;

  SharpQuery select = SharpQuery
        .Select()
        .Field("Id").As("AccountId") // with alias
        .Field("AccountNumber") //name only
        .Where("account.created", Compare.GreaterThanEqual, "'2018-01-01'") //where clause
        .TopN(100)
        .From("account"); //table
  

  // sql output
  var sqlQuery = QueryHelper.GetSqlOutput(select);


  ===========   Generate Select dynamically =============
  
  //Query With Alias:

  // Add a class, Define column name with optional attribute, property name is used as Alias
  
  public class Account
  {
  
         [SqlSharp("Account.Id")] // column name
         public string AccountId { get; set; } // alias

         public string AccountNumber { get; set; }

  }

  // generate query:

  Account a = new Account();
  
  var fields = QueryHelper.GetSelects(a);

    SharpQuery select = SharpQuery
            .Select()
            .Fields(fields.ToArray())
            .Where("account.created", Compare.GreaterThanEqual, "'2018-01-01'")
            .TopN(100)
            .From("account");


    var sqlOutput = QueryHelper.GetSqlOutput(select);

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.3 313 5/14/2018
1.0.2 285 5/14/2018
1.0.1 254 5/14/2018
1.0.0 277 5/10/2018