当前位置: 首页>>代码示例>>C#>>正文


C# DataContext.GetTable方法代码示例

本文整理汇总了C#中DataContext.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# DataContext.GetTable方法的具体用法?C# DataContext.GetTable怎么用?C# DataContext.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataContext的用法示例。


在下文中一共展示了DataContext.GetTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SqlBookmarkRepository

 public SqlBookmarkRepository(string connectionString)
 {
     _context = new DataContext(connectionString);
     _bookmarkTable = _context.GetTable<Bookmark>();
     _bookmarkTagTable = _context.GetTable<BookmarkTag>();
     _tagTable = _context.GetTable<Tag>();
 }
开发者ID:scottmetoyer,项目名称:bookmarks,代码行数:7,代码来源:SqlBookmarkRepository.cs

示例2: FeedRepository

 public FeedRepository(string connectionString)
 {
     _context = new DataContext(connectionString);
     _feedTable = _context.GetTable<Feed>();
     _itemTable = _context.GetTable<Item>();
     _optionTable = _context.GetTable<Option>();
 }
开发者ID:scottmetoyer,项目名称:contingency-reader,代码行数:7,代码来源:FeedRepository.cs

示例3: Main

        static void Main(string[] args)
        {
            DataContext dc = new DataContext(@"Data Source=.\sqlexpress;Initial Catalog=vs2010;Integrated Security=True");

            dc.Log = Console.Out;

            Table<Filho> filhosDoAdao = dc.GetTable<Filho>();

            ObjectDumper.Write(filhosDoAdao);
            Console.WriteLine();

            Filho ooops = new Filho() { NomeFilho = "TIANA", CodigoPessoa = 1 };

            filhosDoAdao.InsertOnSubmit(ooops);
            dc.SubmitChanges();

            ObjectDumper.Write(dc.GetTable<Filho>());
            Console.WriteLine();

            filhosDoAdao.DeleteOnSubmit(ooops);
            dc.SubmitChanges();

            ObjectDumper.Write(dc.GetTable<Filho>());

            Console.ReadKey();
        }
开发者ID:50minutos,项目名称:VS2010,代码行数:26,代码来源:Program.cs

示例4: Main

        static void Main(string[] args)
        {
            DataContext dc = new DataContext(@"Data Source=.\sqlexpress;Initial Catalog=vs2010;Integrated Security=True");

            dc.Log = Console.Out;

            var filhosDoAdao = from f in dc.GetTable<Filho>()
                                  where f.CodigoPessoa == 1
                                  select f;

            ObjectDumper.Write(filhosDoAdao);

            Console.WriteLine();

            foreach (Filho filho in filhosDoAdao)
            {
                filho.NomeFilho += "*";
            }

            dc.SubmitChanges();

            ObjectDumper.Write(dc.GetTable<Filho>());

            Console.ReadKey();
        }
开发者ID:50minutos,项目名称:VS2010,代码行数:25,代码来源:Program.cs

示例5: Main

        static void Main(string[] args)
        {
            DataContext dc = new DataContext(@"Data Source=.\sqlexpress;Initial Catalog=vs2010;Integrated Security=True");

            dc.Log = Console.Out;

            var pessoas = dc.GetTable<Pessoa>();
            var filhos = dc.GetTable<Filho>();

            var todosANSI82 = from p in pessoas
                              from f in filhos
                              where p.CodigoPessoa == f.CodigoPessoa
                              select new { p.NomePessoa, f.NomeFilho };

            ObjectDumper.Write(todosANSI82);

            Console.WriteLine();

            var todosANSI92 = from p in pessoas
                              join f in filhos
                              on p.CodigoPessoa equals f.CodigoPessoa
                              select new { p.NomePessoa, f.NomeFilho };

            ObjectDumper.Write(todosANSI92);

            Console.ReadKey();
        }
开发者ID:50minutos,项目名称:VS2010,代码行数:27,代码来源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            SqlConnection dataConnection = new SqlConnection();
            try
            {
                SqlConnectionStringBuilder SQLConnString = new SqlConnectionStringBuilder();
                SQLConnString.DataSource = ".\\";//连接本地数据库
                SQLConnString.InitialCatalog = "TXGPS_2011";
                SQLConnString.IntegratedSecurity = true;
                dataConnection.ConnectionString = SQLConnString.ConnectionString;
                dataConnection.Open();

                SqlCommand dataCommand = new SqlCommand();
                dataCommand.Connection = dataConnection;
                dataCommand.CommandType = CommandType.Text;
                dataCommand.CommandText = "select * from tUser";

                DataContext db = new DataContext(SQLConnString.ConnectionString);
                Table<tMapX> tMapxs = db.GetTable<tMapX>();            //已经获取数据集
               // var tm = (from t in tMapxs select t).Take(10);// from in select 都是C#关键字,必须小写
                IEnumerable<tMapX> tm = tMapxs.OrderByDescending(ad => ad.id).Take(1);         //降序排列
                Table<tMapxData> tmd=db.GetTable<tMapxData>();
               // Console.WriteLine(tm);
                //tMapX tmapx = tm.Single(t => t.id == 4); //查询单个数据
                //Console.WriteLine(tmapx.Geo);
                foreach (var p in tm)
                {
                    Console.WriteLine(p.id + "--" + p.la + "--" + p.lo + "--" + p.Geo);
                }
                #region LINQ连接表
                var Mapx = from p in tmd join s in tm on p.Lo.ToString() equals (s.lo.ToString()+"00") select new { s.Geo, s.id };
                
                foreach (var p in Mapx)
                {
                    Console.WriteLine(p.id + "--" + p.Geo);
                }
                #endregion
                #region 常规的数据库读取
                //SqlDataReader dataReader = dataCommand.ExecuteReader();
                //while (dataReader.Read())
                //{
                //    int orderid = dataReader.GetInt32(0);
                //    string name = dataReader.GetString(3);
                //    DateTime orderDate = dataReader.GetDateTime(19);
                //    Console.WriteLine(orderid + "--" + name + "--" + orderDate);
                //}
                //dataReader.Close();
                #endregion
            }
            catch (SqlException e)
            {
                Console.WriteLine("Error accessing the database: " + e.Message);
            }
            finally
            {
                dataConnection.Close();
            }

        }
开发者ID:red201432,项目名称:CSharpLearn,代码行数:59,代码来源:Program.cs

示例7: SqlAccountRepository

        public SqlAccountRepository(string connectionString)
        {
            dataContext = new DataContext(connectionString);

            usersTable = dataContext.GetTable<User>();
            rolesTable = dataContext.GetTable<Role>();
            usersInRolesTable = dataContext.GetTable<UsersInRoles>();
        }
开发者ID:NickKip,项目名称:ASPNETCustomMembershipExample,代码行数:8,代码来源:SqlAccountRepository.cs

示例8: Agregar

        //Metodo para la comunicacion con la BD y llamar al SP
        public static void Agregar(int idvuelo, string origen, string destino, int millas, string fecha, int idavion, Decimal precioDolar)
        {
            DataContext dc = new DataContext(myConnection.getConnection());
            var Customers = dc.GetTable<tablaVuelo>();

            var insert = dc.GetTable<tablaVuelo>();

            tablaVuelo newInsert = new tablaVuelo { ID_VUELO = idvuelo, ORIGEN = origen, DESTINO = destino, MILLAS = millas, FECHA = fecha, ID_AVION = idavion, PRECIO_DOLARES = precioDolar,ID_TICKET=0 };
            insert.InsertOnSubmit(newInsert);
            dc.SubmitChanges();
        }
开发者ID:jorland,项目名称:proyecto,代码行数:12,代码来源:Vuelo.cs

示例9: obterConta

        public Conta obterConta(int numero)
        {


            Console.WriteLine("obter " + numero);

            DataContext dc = new DataContext(@"Data Source=wv-toshiba\instancia1;Initial Catalog=ASI;User ID=sa;Password=123");
            Table<Conta> tc = dc.GetTable<Conta>();
            var conta = (from c in dc.GetTable<Conta>()
                         where c.Numero == numero
                         select c).SingleOrDefault();
            return conta;
        }
开发者ID:RASMiranda,项目名称:com.isel.si1314.asi,代码行数:13,代码来源:Program.cs

示例10: TestContextToString

        public void TestContextToString([IncludeDataContexts(ProviderName.SqlServer2008)] string context)
        {
            using (var ctx = new DataContext(context))
            {
                Console.WriteLine(ctx.GetTable<Person>().ToString());

                var q =
                    from s in ctx.GetTable<Person>()
                    select s.FirstName;

                Console.WriteLine(q.ToString());
            }
        }
开发者ID:henleygao,项目名称:linq2db,代码行数:13,代码来源:DataContextTest.cs

示例11: TestContextToString

        public void TestContextToString(string context)
        {
            using (var ctx = new DataContext(context))
            {
                Console.WriteLine(ctx.GetTable<Person>().ToString());

                var q =
                    from s in ctx.GetTable<Person>()
                    select s.FirstName;

                Console.WriteLine(q.ToString());
            }
        }
开发者ID:ili,项目名称:linq2db,代码行数:13,代码来源:DataContextTests.cs

示例12: Main

        static void Main(string[] args)
        {
            DataContext dc = new DataContext(@"Data Source=.\sqlexpress;Initial Catalog=VS2010;Integrated Security=True");

            dc.Log = Console.Out;

            foreach (Pessoa p in dc.GetTable<Pessoa>())
            {
                Console.WriteLine("Pessoa: {0}", p.NomePessoa);

                foreach (Filho f in p.Filhos)
                {
                    Console.WriteLine("   Filho: {0}", f.NomeFilho);
                }
            }

            Console.WriteLine();

            var comFilhos = from p in dc.GetTable<Pessoa>()
                            where p.Filhos.Any()
                            select p;

            ObjectDumper.Write(comFilhos);
            Console.WriteLine();

            var semFilhos = from p in dc.GetTable<Pessoa>()
                            where !p.Filhos.Any()
                            select p;

            ObjectDumper.Write(semFilhos, 1);
            Console.WriteLine();

            var comAlgumFilhoIniciadoPorA = from p in dc.GetTable<Pessoa>()
                                            where p.Filhos.Any(f => f.NomeFilho.StartsWith("A"))
                                            select p;

            ObjectDumper.Write(comAlgumFilhoIniciadoPorA);
            Console.WriteLine();

            var seOsFilhosChamamCHICO = from p in dc.GetTable<Pessoa>()
                                        where p.Filhos.Any()
                                        where p.Filhos.All(f => f.NomeFilho.Equals("CHICO"))
                                        select p;

            ObjectDumper.Write(seOsFilhosChamamCHICO);
            Console.WriteLine();

            Console.ReadKey();
        }
开发者ID:50minutos,项目名称:VS2010,代码行数:49,代码来源:Program.cs

示例13: AmountInsert

        public int AmountInsert(DataContext Context)
        {
            var Amounts = Context.GetTable<CMenuServiceOrderAmount>();
            Amounts.InsertOnSubmit(this);

            return CErrors.ERR_SUC;
        }
开发者ID:cMenu,项目名称:cMenu.Server,代码行数:7,代码来源:CMenuServiceOrderAmount.cs

示例14: buscarporId

        //cambBuscar
        //*creavuelo
        public Vuelo buscarporId(int idVuelo)
        {
            Vuelo vuelo = new Vuelo();
            MyConnection myConnection = new MyConnection();

            DataContext datacontext = new DataContext(myConnection.SQLConnection);

            var Table = datacontext.GetTable<Vuelo>();

            try
            {
                var buscarPorIdVuelo = from vueloId in Table
                                       where vueloId.IdVuelo == idVuelo
                                       select vueloId;
                foreach (Vuelo v in buscarPorIdVuelo)
                {
                    vuelo = v;
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return vuelo;
        }
开发者ID:jennchinchi,项目名称:Proyecto-2-Progra-3,代码行数:29,代码来源:VueloDaImpl.cs

示例15: Main

        static void Main(string[] args)
        {
            DataContext dc = new DataContext(@"Data Source=.\sqlexpress;Initial Catalog=vs2010;Integrated Security=True");

            dc.Log = Console.Out;

            //Table<Pessoa> pessoas = dc.GetTable<Pessoa>();

            var pessoas = from p in dc.GetTable<Pessoa>()
                          select p;

            //ObjectDumper.Write(pessoas);

            Console.WriteLine();

            var nomes = from p in pessoas
                        select p.NomePessoa;

            var lista = from p in nomes
                        where p.Equals("ABEL")
                        select p;

            ObjectDumper.Write(lista);

            Console.ReadKey();
        }
开发者ID:50minutos,项目名称:VS2010,代码行数:26,代码来源:Program.cs


注:本文中的DataContext.GetTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。