示例#1
0
        static void Main(string[] args)
        {
            //linq
            var dbContext     = new AdventureWorks2014Entities();
            var allFirstNames = dbContext.People.Select(p => p.FirstName).ToList();
            var allFullNames  = dbContext.People.Select(p => p.FirstName + " " + p.LastName).ToList();
            var allTims       = dbContext.People.Where(p => p.FirstName == "Tim")
                                .Select(p => p.FirstName + " " + p.LastName).ToList();
            var boolTim = dbContext.People.Any(p => p.FirstName == "Tim");
            var groups  = dbContext.People.GroupBy(p => p.FirstName).ToList();

            foreach (var g in groups)
            {
                Console.WriteLine("Name:{0}\tCount:{1}", g.Key, g.Count());
            }

            var count = dbContext.People.Count(p => p.FirstName == "Tim");

            Console.WriteLine(count);
            //var allPeople = dbContext.People.ToList();
            //foreach (var p in allPeople)
            //{
            //    Console.WriteLine(p.FirstName);
            //}
            //Console.WriteLine("Hello World!");
        }
示例#2
0
 static void Main(string[] args)
 {
     // print to the console, all the products and a few of the fields
     using (var ctx = new AdventureWorks2014Entities())
     {
         foreach (var prod in ctx.Products)
         {
             Console.WriteLine(prod.Name + " -- $" + prod.ListPrice);
         }
     }
 }
示例#3
0
        public static void Run()
        {
            bool next_opt = true;

            //Base de datos que contiene estructura de tablas
            using (DataEF = new AdventureWorks2014Entities())
            {
                Console.WriteLine("----- Ejecución de versión EF del programa -----\n");

                do
                {
                    switch (Menu())
                    {
                    case 0:
                        next_opt = false;
                        break;

                    case 1:
                        EFShowProducts();
                        break;

                    case 2:
                        EFShowOrderHeaders();
                        break;

                    case 3:
                        EFManageOrderHeader();
                        break;

                    default:
                        Console.WriteLine("\n--- ERROR: Opción incorrecta. Reintentelo --\n");
                        break;
                    }
                }while (next_opt);
            }
        }
 public EmployeeRepository(AdventureWorks2014Entities adventureWorks2014Entities)
 {
     this.db = adventureWorks2014Entities;
 }
示例#5
0
 public AutoMapperAdapter()
 {
     InitialAutomapper();
     this.dbContext = null;
 }
示例#6
0
 public BaseRepository()
 {
     _dbContext = new AdventureWorks2014Entities();
     _entities  = _dbContext.Set <TBusiness>();
 }
示例#7
0
 public AdventureWorksUnitOfWork(AdventureWorks2014Entities dbContext) : base(dbContext)
 {
 }
 public ValueInjecterAdapter()
 {
     this.mapper = new MapperInstance();
     this.MapperConfigure(this.mapper);
     this.dbContext = null;
 }
 public VanilaEfAdapter()
 {
     this.dbContext = null;
 }