@manhng

Welcome to my blog!

Api Convert Currency

January 5, 2022 16:03

Api Convert Currency (edit)

  • DbUp: Chạy script để đồng bộ database
  • Oracle Server Side Paging: Paging phía Server truyền lên PageSize, PageIndex dùng câu Raw SQL
  • Dapperdùng với Raw SQL
  • cUrl: Chuyển đổi tiền tệ giữa VND-USD-JPY (Việt-Nhật-Mỹ) dùng API online public
  • Oracle DbDataReader: Pagination in Oracle - @manhng
  • Oracle Command Timeout: Pagination in Oracle - @manhng

Pagination in Oracle - @manhng

Api Convert Currency Online

1 VND to USD - Vietnamese Dongs to US Dollars Exchange Rate (xe.com)

1 USD to VND - US Dollars to Vietnamese Dongs Exchange Rate (xe.com)

1 JPY to VND - Japanese Yen to Vietnamese Dongs Exchange Rate (xe.com)

1 VND to JPY - Vietnamese Dongs to Japanese Yen Exchange Rate (xe.com)

cURL - @manhng

curl -X GET "https://www.xe.com/currencyconverter/convert/?Amount=1&From=VND&To=USD"

Dapper

Working With Parameters When Using Dapper | Learn Dapper

Paging

Paging in ASP.NET Core Web API - Code Maze (code-maze.com)

Paging Oracle

SELECT A.*, CEIL(TOTAL_NUM_ROWS / 10) TOTAL_NUM_PAGES
FROM ( SELECT B.ID, B.FIRST_NAME, B.LAST_NAME, B.UPLOAD_DATE, row_number() OVER(ORDER BY UPLOAD_DATE DESC) rn, COUNT(*) OVER() TOTAL_NUM_ROWS
FROM PERSON B
) A
WHERE rn BETWEEN (1 - 1) * 10 + 1 AND 1 * 10


SELECT A.*, CEIL(TOTAL_NUM_ROWS / 10) TOTAL_NUM_PAGES
FROM ( SELECT B.ID, B.FIRST_NAME, B.LAST_NAME, B.UPLOAD_DATE, row_number() OVER(ORDER BY UPLOAD_DATE DESC) rn, COUNT(*) OVER() TOTAL_NUM_ROWS
FROM PERSON B
) A
WHERE rn BETWEEN (2 - 1) * 10 + 1 AND 2 * 10


SELECT A.*, CEIL(TOTAL_NUM_ROWS / :PAGESIZE) TOTAL_NUM_PAGES
FROM ( SELECT B.ID, B.FIRST_NAME, B.LAST_NAME, B.UPLOAD_DATE, row_number() OVER(ORDER BY UPLOAD_DATE DESC) rn, COUNT(*) OVER() TOTAL_NUM_ROWS
FROM PERSON B
) A
WHERE rn BETWEEN (:PAGEINDEX - 1) * :PAGESIZE + 1 AND :PAGEINDEX * :PAGESIZE

DbDataReader Oracle

Retrieving Data Using a DataReader - ADO.NET | Microsoft Docs

DbUp Oracle

Releases · DbUp/DbUp (github.com)

DbUp/DbUp: DbUp is a .NET library that helps you to deploy changes to SQL Server databases. It tracks which SQL scripts have been run already, and runs the change scripts that are needed to get your database up to date. (github.com)

Using Database Project and DbUp for database management - Kamil Grzybek

Simplifying database development with docker and DbUp | Blog (mcode.it) (HAY HAY HAY)

Snippet

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="dbup-core" version="4.5.0" targetFramework="net472" />
  <package id="dbup-oracle" version="4.5.0" targetFramework="net472" />
  <package id="Oracle.ManagedDataAccess" version="18.3.0" targetFramework="net472" />
</packages>

Snippet

using DbUp;
using DbUp.Oracle;
using System;
using System.Linq;
using System.Reflection;
 
namespace Oracle.DbUp
{
    class Program
    {
        [Obsolete]
        static void Main(string[] args)
        {
            var connectionString =
                args.FirstOrDefault()
                ?? "DATA SOURCE=localhost/ORCL;USER ID=sa;PASSWORD=123456;Min Pool Size=5;Decr Pool Size=10;PERSIST SECURITY INFO=True";
            var upgrader = DeployChanges.To
                .OracleDatabase(connectionString)
                .WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly())
                .LogToConsole()
                .Build();
            var result = upgrader.PerformUpgrade();
            if (!result.Successful)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(result.Error);
                Console.ResetColor();
                Environment.Exit(-1);
            }
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(value: "Success!");
            Console.ResetColor();
            Environment.Exit(0);
        }
    }
}

 

Categories

Recent posts