static void RunL2s()
        {
            using (var db = new testDataContext())
            {
                db.Log = Console.Out;

                var q = from t in db.tables
                        select new
                {
                    TableName   = t.name,
                    ColumnCount = t.all_columns.Count()
                };
                foreach (var t in q)
                {
                    Console.WriteLine("{0} {1}", t.TableName, t.ColumnCount);
                }
            }
            using (var otherDB = new other.otherDataContext())
            {
                var prods = from p in otherDB.Products
                            select p;


                DataTable t = prods.Take(10).ToDataTable();


                t.WriteXml(Console.Out);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            watch.Start();
            testDataContext      db       = new testDataContext();
            Table <BCS_District> district = db.GetTable <BCS_District>();

            db.Log = Console.Out;
            //IQueryable<BCS_District> query = from a in district where a.DepartmentCode == "21" select a;
            //foreach (var item in query)
            //{
            //    Console.WriteLine(item.DistrictName, item.CreateDT);
            //}



            //// IQueryable<BCS_Charge> query = db.BCS_Charge.Take<BCS_Charge>(100000);
            ////查询方法
            //IQueryable<BCS_District> query1 = db.BCS_District.Where<BCS_District>(x=>x.Dis_ID>3);
            //查询语法
            //db.Log = Console.Out;
            IQueryable <BCS_District> query2 = from x in district where x.Dis_ID >= 3 select x;

            watch.Stop();
            Console.WriteLine(query2);
            Console.WriteLine(watch.ElapsedMilliseconds);
            watch.Restart();
            string sql = @"SELECT TOP 100000 [Charge_ID] ,[InvoiceCode],[PriceMonth_ID],[BM_ID]
      ,[GetMoneyTime]
      ,[DepartmentCode]
      ,[CM_ID]
      ,[UsedWaterNumber]
      ,[GetMoney]
      ,[BankOfDeposit]
      ,[GetMoneyPersonId]
      ,[GetMoneyPersonName]
      ,[state]
      ,[PlanMoney]
      ,[LastBalance]
      ,[ThisBalance]
      ,[InvoiceOver]
      ,[BookOver]
      ,[OldInvoiceCode]
      ,[PosYn]
      ,[PosMoney]
      ,[CardType]
      ,[AdvanceYn]
      ,[MoneyType]
      ,[BalanceDt]
      ,[AdvanceReturn]
      ,[CreateDT]
      ,[ReviseDT]
      ,[Creator]
      ,[Operator]
      ,[Old定价]
      ,[Old年月]
      ,[Old客户]
      ,[Old水表]
      ,[Old支付方式]
      ,[OldUser]
      ,[otherOrderCode] FROM [FFSLJ].[dbo].[BCS_Charge]";

            ExcuteTable(sql, CommandType.Text);
            watch.Stop();
            Console.WriteLine(watch.ElapsedMilliseconds);
            Console.ReadKey();
        }