在 resx 內找到圖檔,就可以順利匯出囉
- 參考資料
- StackOverFlow 討論
using FastMember;
using System;
using System.Linq;
namespace FastMemberDemo
{
class Program
{
static void Main(string[] args)
{
TypeAccessor Accessor = TypeAccessor.Create(typeof(Employee));
MemberSet Members = Accessor.GetMembers();
Console.WriteLine("------- Member 相關");
Console.WriteLine("-- 只列出公開屬性,所以沒有 Status");
foreach (Member m in Members)
{
Console.WriteLine(m.Name);
}
Console.WriteLine("-- 屬性存在測試");
string PropertyName = "PropertyNotExists";
if (Members.Any(m => m.Name == PropertyName) == false)
Console.WriteLine($"該屬性 {PropertyName} 不存在");
Console.WriteLine("------- Accessor 相關");
Console.WriteLine("-- Property 取值和設定測試");
Employee employee = new Employee()
{
EmployeeID = 1,
EmployeeName = "員工姓名",
Birthday = new DateTime(2021, 8, 13)
};
// 設定 Property 值
Accessor[employee, nameof(Employee.EmployeeName)] = "哇係 FastMember 啦";
Console.WriteLine($"透過 FastMember 設定 EmployeeName:{employee.EmployeeName}");
// 取得 Property 值
DateTime birthday = (DateTime)Accessor[employee, nameof(Employee.Birthday)];
Console.WriteLine($"生日為 {birthday}");
}
}
public class Employee
{
public int EmployeeID { get; set; }
public string EmployeeName { get; set; }
public DateTime Birthday { get; set; }
/// <summary>
/// 故意設定為 private 來測試的
/// </summary>
private bool Status { get; set; }
public int? Age { get; set; }
}
}
-- 建立測試 Index
CREATE INDEX IX_SalesOrderDetail_ProductID ON [Sales].[SalesOrderDetail] (ProductID)
INCLUDE(OrderQty)
-- 常使用的 Group By 彙總方式
SELECT
ProductID ,
SUM(OrderQty) AS OrderQty
FROM [Sales].[SalesOrderDetail]
WHERE ProductID = 707
GROUP BY ProductID
-- 視窗函數彙總方式
SELECT
DISTINCT
ProductID ,
SUM(OrderQty) OVER (PARTITION BY ProductID ORDER BY ProductID)
FROM [Sales].[SalesOrderDetail]
WHERE ProductID = 707
以上兩種方式可以獲得相同結果,但在效能上會有差異