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

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 @ 2010-04-17 21:38  CityWalker  阅读(182)  评论(0编辑  收藏  举报
天天来