Created
May 3, 2020 06:31
-
-
Save usausa/715e7dfd1a7cb26deaedef81c5e88d9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <auto-generated /> | |
namespace Example.ConsoleApplication.Accessor | |
{ | |
using System; | |
using System.Linq; | |
using static Smart.Data.Accessor.Scripts.ScriptHelper; | |
public sealed class IExampleAccessor_Impl : global::Example.ConsoleApplication.Accessor.IExampleAccessor | |
{ | |
private readonly global::Smart.Data.Accessor.Engine.ExecuteEngine _engine; | |
private readonly global::Smart.Data.IDbProvider _provider; | |
private readonly global::Smart.Data.Accessor.Engine.ExecuteEngine.InParameterSetup _setupParameter1_0; | |
private readonly global::Smart.Data.Accessor.Engine.ExecuteEngine.InParameterSetup _setupParameter1_1; | |
private readonly global::Smart.Data.Accessor.Engine.ExecuteEngine.InParameterSetup _setupParameter1_2; | |
private readonly global::Smart.Data.Accessor.Engine.ResultMapperCache<global::Example.ConsoleApplication.Models.DataEntity> _mapper2; | |
private readonly global::Smart.Data.Accessor.Engine.ExecuteEngine.InParameterSetup _setupParameter2_0; | |
public IExampleAccessor_Impl(global::Smart.Data.Accessor.Engine.ExecuteEngine engine) | |
{ | |
this._engine = engine; | |
this._provider = (global::Smart.Data.IDbProvider)engine.ServiceProvider.GetService(typeof(global::Smart.Data.IDbProvider)); | |
var method1 = global::Smart.Data.Accessor.Runtime.RuntimeHelper.GetInterfaceMethodByNo(GetType(), typeof(global::Example.ConsoleApplication.Accessor.IExampleAccessor), 1); | |
this._setupParameter1_0 = global::Smart.Data.Accessor.Runtime.RuntimeHelper.CreateInParameterSetup(engine, typeof(global::System.Int64), method1, -1, typeof(global::Example.ConsoleApplication.Models.DataEntity), "Id"); | |
this._setupParameter1_1 = global::Smart.Data.Accessor.Runtime.RuntimeHelper.CreateInParameterSetup(engine, typeof(global::System.String), method1, -1, typeof(global::Example.ConsoleApplication.Models.DataEntity), "Name"); | |
this._setupParameter1_2 = global::Smart.Data.Accessor.Runtime.RuntimeHelper.CreateInParameterSetup(engine, typeof(global::System.String), method1, -1, typeof(global::Example.ConsoleApplication.Models.DataEntity), "Type"); | |
var method2 = global::Smart.Data.Accessor.Runtime.RuntimeHelper.GetInterfaceMethodByNo(GetType(), typeof(global::Example.ConsoleApplication.Accessor.IExampleAccessor), 2); | |
this._mapper2 = new global::Smart.Data.Accessor.Engine.ResultMapperCache<global::Example.ConsoleApplication.Models.DataEntity>(engine, false); | |
this._setupParameter2_0 = global::Smart.Data.Accessor.Runtime.RuntimeHelper.CreateInParameterSetup(engine, typeof(global::System.String), method2, 0, null, ""); | |
} | |
[global::Smart.Data.Accessor.Runtime.MethodNoAttribute(0)] | |
public void Create() | |
{ | |
using (var _con = this._provider.CreateConnection()) | |
using (var _cmd = _con.CreateCommand()) | |
{ | |
_cmd.CommandText = "CREATE TABLE IF NOT EXISTS Data (Id int PRIMARY KEY, Name text, Type text)"; | |
_con.Open(); | |
this._engine.Execute(_cmd); | |
} | |
} | |
[global::Smart.Data.Accessor.Runtime.MethodNoAttribute(1)] | |
public void Insert(global::Example.ConsoleApplication.Models.DataEntity entity) | |
{ | |
using (var _con = this._provider.CreateConnection()) | |
using (var _cmd = _con.CreateCommand()) | |
{ | |
this._setupParameter1_0.Setup(_cmd, "_p0", entity.Id); | |
this._setupParameter1_1.Setup(_cmd, "_p1", entity.Name); | |
this._setupParameter1_2.Setup(_cmd, "_p2", entity.Type); | |
_cmd.CommandText = "INSERT INTO Data (Id, Name, Type) VALUES (@_p0, @_p1, @_p2)"; | |
_con.Open(); | |
this._engine.Execute(_cmd); | |
} | |
} | |
[global::Smart.Data.Accessor.Runtime.MethodNoAttribute(2)] | |
public global::System.Collections.Generic.List<global::Example.ConsoleApplication.Models.DataEntity> QueryDataList(global::System.String type, global::System.String order) | |
{ | |
using (var _con = this._provider.CreateConnection()) | |
using (var _cmd = _con.CreateCommand()) | |
{ | |
var _flag0 = false; | |
var _sql = new global::System.Text.StringBuilder(64); | |
_sql.Append("SELECT * FROM Data"); | |
if (!String.IsNullOrEmpty(type)) { | |
_flag0 = true; | |
_sql.Append(" WHERE Type = @_p0"); | |
} | |
if (!String.IsNullOrEmpty(order)) { | |
_sql.Append(" ORDER BY "); | |
_sql.Append(order); | |
} | |
if (_flag0) | |
{ | |
this._setupParameter2_0.Setup(_cmd, "_p0", type); | |
} | |
_cmd.CommandText = _sql.ToString(); | |
_con.Open(); | |
var _result = this._engine.QueryBuffer<global::Example.ConsoleApplication.Models.DataEntity>(_cmd, this._mapper2); | |
return _result; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment