This file contains 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
using Newtonsoft.Json; | |
namespace API.SDK; | |
public interface IChatGpt | |
{ | |
Task<Result> Call(string message, string model = "text-davinci-003"); | |
} | |
public class ChatGpt : IChatGpt |
This file contains 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
// From: https://stackoverflow.com/a/55497919 | |
using Microsoft.Extensions.Configuration; | |
var myConfiguration = new Dictionary<string, string> | |
{ | |
{"Key1", "Value1"}, | |
{"Nested:Key1", "NestedValue1"}, | |
{"Nested:Key2", "NestedValue2"} | |
}; |
This file contains 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
using System; | |
namespace CleanCode.NestedConditionals | |
{ | |
public class Customer | |
{ | |
public int LoyaltyPoints { get; set; } | |
} | |
public class Reservation |
This file contains 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
using System; | |
using System.Collections.Generic; | |
namespace CleanCode.LongParameterList | |
{ | |
public class LongParameterList | |
{ | |
public IEnumerable<Reservation> GetReservations( | |
DateTime dateFrom, DateTime dateTo, | |
User user, int locationId, |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Net.Mail; | |
namespace CleanCode.Comments | |
{ | |
public class Comments | |
{ | |
private int _pf; // pay frequency | |
private DbContext _dbContext; |
This file contains 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
namespace CleanCode.MagicNumbers | |
{ | |
public class MagicNumbers | |
{ | |
public void ApproveDocument(int status) | |
{ | |
if (status == 1) | |
{ | |
// ... | |
} |
This file contains 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
namespace CleanCode.VariableDeclarationsAtTheTop | |
{ | |
public class PayCalculator | |
{ | |
private PayFrequency _payFrequency; | |
public PayCalculator(PayFrequency payFrequency) | |
{ | |
_payFrequency = payFrequency; |
This file contains 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
using System; | |
using System.Collections.Generic; | |
namespace CleanCode.OutputParameters | |
{ | |
public class OutputParameters | |
{ | |
public void DisplayCustomers() | |
{ | |
int totalCount = 0; |
This file contains 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
/* | |
刪除完全重複資料 | |
*/ | |
--step I:建立資料 | |
declare @temptable table | |
( | |
name nvarchar(10), | |
tel varchar(10) | |
); |
This file contains 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
/* | |
DATEADD與DATEDIFF的應用: | |
1. DATEDIFF:起始日與迄日之間差異了幾天(Day)/月(MONTH)/季(QUARTER)/年(YEAR) | |
- 常見用法:DATEDIFF(Day/Week/MONTH/QUARTER/YEAR, 起日, 迄日) | |
- 起日/迄日: | |
- 日期部份若放為『0』或『''』,代表資料庫最小時間1900-01-01 00:00:00.000。 | |
- 同理,若為『-1』,代表1899-12-31 00:00:00.000。 | |
2. DATEADD:增加/減少天數(Day)/月(MONTH)/季(QUARTER)/年(YEAR),範例如下: | |
- 加一個月 DATEADD(MONTH, 1 ,GETDATE()) |