Пример #1
0
 static void Main(string[] args)
 {
     using (var ctx = new AdventureWorksEntitiesEmployee())
     {
         foreach (var emp in ctx.Employee.Where(e => e.Gender == "F").Take(5))
         {
             Console.WriteLine("{0} {1}, born {2}",
                               emp.Person.FirstName,
                               emp.Person.LastName,
                               emp.BirthDate.ToLongDateString()
                               );
         }
         Console.Read();
     }
 }
Пример #2
0
        static void Main(string[] args)
        {
            using (var ctx = new AdventureWorksEntitiesEmployee())
            {
                var newP = new BusinessEntity {
                    ModifiedDate = DateTime.Now,
                    rowguid      = Guid.NewGuid()
                };

                Console.WriteLine("BusinessEntityID before insert : {0}",
                                  newP.BusinessEntityID);

                ctx.BusinessEntities.AddObject(newP);
                ctx.SaveChanges();

                Console.WriteLine("BusinessEntityID after insert :  {0}",
                                  newP.BusinessEntityID);
            }

            Console.Read();
        }
Пример #3
0
        static void Main(string[] args)
        {
            using (var ctx = new AdventureWorksEntitiesEmployee())
            {
                var qry = from e in ctx.Employee
                          where e.Gender == "F"
                          select new
                {
                    e.Person.FirstName,
                    e.Person.LastName,
                    e.BirthDate
                };

                foreach (var emp in qry.Take(5))
                {
                    Console.WriteLine("{0} {1}, born {2}",
                                      emp.FirstName,
                                      emp.LastName,
                                      emp.BirthDate.ToLongDateString()
                                      );
                }
                Console.Read();
            }
        }