Ejemplo n.º 1
0
        public string ToSql()
        {
            var sql = new StringWriter();

            sql.WriteLine("MERGE ExchangeRate AS Target");
            sql.WriteLine("USING (SELECT {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}) As Source (BankId, DayOfYear, Year, Date, Month, MonthName, DayName, UtcLastUpdateOn, BuyRate, SaleRate)", BankId.ToSql(), DayOfYear.ToSql(), Year.ToSql(), Date.ToSql(), Month.ToSql(), MonthName.ToSql(), DayName.ToSql(), UtcLastUpdateOn.ToSql(), BuyRate.ToSql(), SaleRate.ToSql());
            sql.WriteLine("ON Target.BankId = {0} And Target.DayOfYear = {1} And Target.Year = {2}", BankId.ToSql(), DayOfYear.ToSql(), Year.ToSql());
            sql.WriteLine("WHEN MATCHED THEN");
            sql.WriteLine(" UPDATE SET Month = {0}, MonthName = {1}, DayName = {2}, UtcLastUpdateOn = {3}, BuyRate = {4}, SaleRate = {5}", Month.ToSql(), MonthName.ToSql(), DayName.ToSql(), UtcLastUpdateOn.ToSql(), BuyRate.ToSql(), SaleRate.ToSql());
            sql.WriteLine("WHEN NOT MATCHED THEN");
            sql.WriteLine(" INSERT (BankId, DayOfYear, Year, Date, Month, MonthName, DayName, UtcLastUpdateOn, BuyRate, SaleRate)");
            sql.WriteLine(" VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9});", BankId.ToSql(), DayOfYear.ToSql(), Year.ToSql(), Date.ToSql(), Month.ToSql(), MonthName.ToSql(), DayName.ToSql(), UtcLastUpdateOn.ToSql(), BuyRate.ToSql(), SaleRate.ToSql());
            return(sql.ToString());
        }