コード例 #1
0
        public IEnumerable <Person> ChangeAge_FilterPersonsMinAge(int change, int minAge)
        {
            IQueryable <Person> linq =
                from Person p in context.Persons
                where p.Age >= minAge
                select p;

            foreach (Person p in context.Persons)
            {
                p.Age = p.Age + change;
                context.SubmitChanges();
            }

            return(linq.ToList());
        }
コード例 #2
0
 /// <summary>
 /// Adds given Person entity to database context, and ultimately to database table.
 /// </summary>
 /// <param name="p">Person entity to add to database.</param>
 public void AddPerson(Person p)
 {
     context.Persons.InsertOnSubmit(p);
     context.SubmitChanges();
 }