2021年2月20日 星期六

epplus 排序欄位

從第5列第2行到最後一列最後一行排序,先排序第2行再來第3行

ws.Cells[5, 2, ws.Dimension.Rows, ws.Dimension.Columns].Sort(new int[] { 0,1 });

/// <summary>
/// Sort the range by value
/// </summary>
/// <param name="columns">The column(s) to sort by within the range. Zerobased</param>
/// <param name="descending">Descending if true, otherwise Ascending. Default Ascending. Zerobased</param>
/// <param name="culture">The CultureInfo used to compare values. A null value means CurrentCulture</param>
/// <param name="compareOptions">String compare option</param>
public void Sort(int[] columns, bool[] descending=null, CultureInfo culture=null, CompareOptions compareOptions=CompareOptions.None)

2021年2月3日 星期三

使用 liff 取得 lineid

新增 liff app
前往 LINE Developers > Provider > channels > 點選 line login channel > liff

取得 lineid
<script src="https://static.line-scdn.net/liff/edge/2/sdk.js"></script>
liff.init({
                liffId: '...'
            }).then(function () {
                if (liff.isLoggedIn()) {
                    liff.getProfile().then(profile => {
                        alert(profile.userId); // lineid
                    });
                }
                else {
                    liff.login({ redirectUri: new URL(window.location.href) }); // 返回時保留呼叫前的參數
                }
            }).catch(function (error) {
                console.log(error);
            });

Entity Framework 建立新物件並儲存後馬上取得關聯資料

使用 CreateProxy 建立物件,不要直接 new var newmodel = _contextXXX.CreateProxy<yyy>(); ... _contextXXX.yyy.Add(newmodel); await _contextXXX.SaveC...