Esempio n. 1
0
        public void CreateAccessFunc()
        {
            var func  = AccessExpressionUtility.CreateAccessFunc <TestClass>("Value2");
            var func2 = AccessExpressionUtility.CreateAccessFunc <TestClass>("Value3");

            var instance = new TestClass();

            Assert.Equal(instance.Value2, func.Compile()(instance));
            Assert.Equal(instance.Value3, func2.Compile()(instance));
        }
Esempio n. 2
0
 /// <summary>
 /// 使用指定屬性進行Group操作
 /// </summary>
 /// <typeparam name="TSource">元素類別</typeparam>
 /// <typeparam name="TKey">主鍵類別</typeparam>
 /// <param name="source">目前實例</param>
 /// <param name="key">主鍵屬性名稱</param>
 /// <returns>使用指定key進行Group結果</returns>
 public static IEnumerable <IGrouping <TKey, TSource> > GroupBy <TSource, TKey>(this IEnumerable <TSource> source, string key)
 {
     return(source.GroupBy(AccessExpressionUtility.CreateAccessFunc <TSource, TKey>(key)));
 }