public void GivenAnotherPerson_WhenSearching_IsAbleToFindHim()
        {
            // Arrange
            using (var entities = new DataContextModelContainer())
            {
                var person = new Person { FirstName = "Rune", LastName = "Rudberg" };
                person.ContextId = CurrentContextId;

                entities.People.AddObject(person);
                entities.SaveChanges();
            }

            // Act
            using (var search = new DataContextModelContainer())
            {
                var people = from p in search.People
                             where p.FirstName == "Rune" && p.ContextId == CurrentContextId
                             select p;

                var foundPerson = people.First();
                var countOfHits = people.Count();

                // Assert
                Assert.AreEqual(1, countOfHits);
                Assert.AreEqual("Rudberg", foundPerson.LastName);
            }
        }
        public void GivenPerson_WhenSearching_IsAbleToFindHim()
        {
            int contextId;

            // Arrange
            using (var entities = new DataContextModelContainer())
            {
                var currentContext = new Context
                    {
                        Name = "Testcontext 1234",
                        IsTest = true,
                        DateCreated = DateTime.Now
                    };

                entities.Contexts.AddObject(currentContext);

                var person = new Person { FirstName = "Rune", LastName = "Rystad" };
                person.ContextId = currentContext.Id;
                entities.People.AddObject(person);
                entities.SaveChanges();

                contextId = currentContext.Id;
            }

            // Act
            using (var search = new DataContextModelContainer())
            {
                var people = from p in search.People
                             where p.FirstName == "Rune" && p.ContextId == contextId
                             select p;
                // Assert
                Assert.AreEqual(1, people.Count());
                Assert.AreEqual("Rystad", people.First().LastName);
            }
        }
 public void Save(Person person)
 {
     using (var model = new DataContextModelContainer())
     {
         person.ContextId = context.Id;
         model.People.AddObject(person);
         model.SaveChanges();
     }
 }
 /// <summary>
 /// Create a new Person object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="contextId">Initial value of the ContextId property.</param>
 public static Person CreatePerson(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.Int32 contextId)
 {
     Person person = new Person();
     person.Id = id;
     person.FirstName = firstName;
     person.LastName = lastName;
     person.ContextId = contextId;
     return person;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the People EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPeople(Person person)
 {
     base.AddObject("People", person);
 }