6. 串联操作符—【LINQ标准查询操作符】

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class Concat_LINQ
    {
        static string ContextString = System.Configuration.ConfigurationSettings.AppSettings["ContextString"].ToString();
        static DataContext context = new DataContext(ContextString);
        static Table<Contact> contacts = context.GetTable<Contact>();
        static Table<SalesOrderHeader> orders = context.GetTable<SalesOrderHeader>();
 
        public static void Concat_Print()
        {          
            string[] FirstName = new string[] { "Robert", "Kim", "Lili", "Anna", };
            string[] LastName = new string[] { "_Adams", "_Adina", "_Alameda", "_Albury" };
 
            var conCatQuery = FirstName.Select(f => f).Concat(LastName.Select(l => l));
 
            var query = contacts.Select(c => c.LastName).Concat(orders.Select(ord => ord.CustomerID.ToString()));
 
            foreach (var item in conCatQuery)
            {
                Console.WriteLine(item);
            }
 
            Console.ReadKey();
        }
    }
posted @   CityWalker  阅读(182)  评论(0编辑  收藏  举报
努力加载评论中...
天天来
点击右上角即可分享
微信分享提示