コード例 #1
0
ファイル: Program.cs プロジェクト: gerakul/FastSql
        static async Task Sample3Async()
        {
            // simple command
            var q1 = SimpleCommand.ExecuteQueryAsync<Employee>(new ExecutionOptions(fieldsSelector: FieldsSelector.Source), CancellationToken.None,
              connStr, "select ID, CompanyID, Name, Phone from Employee where CompanyID = @p0", 1);
            var arr1 = await q1.ToArray();

            // mapped command with anonymous type
            var a = new { CompanyID = 1 };
            var q2 = MappedCommand.Compile(a, "select ID, CompanyID, Name, Phone from Employee where CompanyID = @CompanyID")
              .ExecuteQueryAsync<Employee>(connStr, a, new ExecutionOptions(fieldsSelector: FieldsSelector.Source));
            var arr2 = await q2.ToArray();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: gerakul/FastSql
        // Using FieldsSelector option: there will only be filled columns contains in source
        static void Sample3()
        {
            // simple command
            var q1 = SimpleCommand.ExecuteQuery<Employee>(new ExecutionOptions(fieldsSelector: FieldsSelector.Source),
              connStr, "select ID, CompanyID, Name, Phone from Employee where CompanyID = @p0", 1);
            var arr1 = q1.ToArray();

            // mapped command with anonymous type
            var a = new { CompanyID = 1 };
            var q2 = MappedCommand.Compile(a, "select ID, CompanyID, Name, Phone from Employee where CompanyID = @CompanyID")
              .ExecuteQuery<Employee>(connStr, a, new ExecutionOptions(fieldsSelector: FieldsSelector.Source));
            var arr2 = q2.ToArray();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: gerakul/FastSql
        static async Task Sample10Async()
        {
            // simple command
            await SimpleCommand.ExecuteNonQueryAsync(connStr, "update Company set Name = @p1 where ID = @p0", 2, "Updated Co");

            // mapped command with anonymous type
            var a = new { ID = 2, Name = "Updated Co1" };
            await MappedCommand.ExecuteNonQueryAsync(connStr, "update Company set Name = @Name where ID = @ID", a);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: gerakul/FastSql
        // Query without retrieving data
        static void Sample10()
        {
            // simple command
            SimpleCommand.ExecuteNonQuery(connStr, "update Company set Name = @p1 where ID = @p0", 2, "Updated Co");

            // mapped command with anonymous type
            var a = new { ID = 2, Name = "Updated Co1" };
            MappedCommand.ExecuteNonQuery(connStr, "update Company set Name = @Name where ID = @ID", a);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: gerakul/FastSql
        static async Task Sample8Async()
        {
            // simple command
            var empName1 = await SimpleCommand.ExecuteQueryFirstColumnAsync<string>(connStr, "select Name from Employee where CompanyID = @p0 and Age > @p1", 1, 40).First();

            // mapped command with anonymous type
            var a = new { CompanyID = 1, Age = 40 };
            var empName2 = await MappedCommand.Compile(a, "select Name from Employee where CompanyID = @CompanyID and Age > @Age")
              .ExecuteQueryFirstColumnAsync<string>(connStr, a).First();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: gerakul/FastSql
 static async Task Sample6Async()
 {
     // simple command
     var proto = new { Company = default(string), Emp = default(string) };
     var q1 = SimpleCommand.ExecuteQueryAnonymousAsync(proto, connStr, "select E.Name as Emp, C.Name as Company from Employee E join Company C on E.CompanyID = C.ID");
     var arr1 = await q1.ToArray();
 }