PromptSql 0.0.1

This library was developed to present your basic ado net operations with a simple fluent interface.

Install-Package PromptSql -Version 0.0.1
dotnet add package PromptSql --version 0.0.1
<PackageReference Include="PromptSql" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PromptSql --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PromptSql, 0.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install PromptSql as a Cake Addin
#addin nuget:?package=PromptSql&version=0.0.1

// Install PromptSql as a Cake Tool
#tool nuget:?package=PromptSql&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

PromptSql

This library was developed to present your basic ado net operations with a simple fluent interface.

How to use?

1. Create a PromptSqlModule
public class SqlModule : PromptSqlModule
{
    public override string GetConnectionString()
    {
        return ConfigurationManager.AppSettings["DefaultConnection"];
    }
}
2. Command usage
        string sqlCommand = @"UPDATE [dbo].[Books] SET [Description] = 'Test Description' WHERE [Id] = 1";

        new SqlOperations<SqlModule>()
            .BeginOperation(x => x.CreateOptions(sqlCommand))
            .GetCommand()
            .ExecuteNonQuery();
            
3. Query usage

In order to make inquiries, you must first have a model where you will host the data and a sqlmapper.

get the model as below

public class Book
{
    public int Id { get; set; }
    public string ISBN { get; set; }
    public string Description { get; set; }
    public int? Age { get; set; }
    public DateTime? CreateDate { get; set; }

}

sqlmapper for this model should be as follows

public class BookMapper : SqlMapper<Book>
{
    protected override Book Map(DataRow source)
    {
        return new Book
        {
            Id = source.Field<int>("Id"),
            ISBN = source.Field<string>("ISBN"),
            Age = source.Field<int?>("Age"),
            CreateDate = source.Field<DateTime?>("CreateDate"),
            Description = source.Field<string>("Description")
        };
    }
}

now we are ready to query

        var data = new SqlOperations<SqlModule>()
            .BeginOperation(x => x.CreateOptions(query))
            .GetQuery<Book, BookMapper>()
            .GetData();
            

that's all

PromptSql

This library was developed to present your basic ado net operations with a simple fluent interface.

How to use?

1. Create a PromptSqlModule
public class SqlModule : PromptSqlModule
{
    public override string GetConnectionString()
    {
        return ConfigurationManager.AppSettings["DefaultConnection"];
    }
}
2. Command usage
        string sqlCommand = @"UPDATE [dbo].[Books] SET [Description] = 'Test Description' WHERE [Id] = 1";

        new SqlOperations<SqlModule>()
            .BeginOperation(x => x.CreateOptions(sqlCommand))
            .GetCommand()
            .ExecuteNonQuery();
            
3. Query usage

In order to make inquiries, you must first have a model where you will host the data and a sqlmapper.

get the model as below

public class Book
{
    public int Id { get; set; }
    public string ISBN { get; set; }
    public string Description { get; set; }
    public int? Age { get; set; }
    public DateTime? CreateDate { get; set; }

}

sqlmapper for this model should be as follows

public class BookMapper : SqlMapper<Book>
{
    protected override Book Map(DataRow source)
    {
        return new Book
        {
            Id = source.Field<int>("Id"),
            ISBN = source.Field<string>("ISBN"),
            Age = source.Field<int?>("Age"),
            CreateDate = source.Field<DateTime?>("CreateDate"),
            Description = source.Field<string>("Description")
        };
    }
}

now we are ready to query

        var data = new SqlOperations<SqlModule>()
            .BeginOperation(x => x.CreateOptions(query))
            .GetQuery<Book, BookMapper>()
            .GetData();
            

that's all

Release Notes

This library was developed to present your basic ado net operations with a simple fluent interface.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.0.1 329 1/19/2020