void saving_something_that_has_confirmation_to_the_database() { before = () => { seed.CreateTable("Persons", new dynamic[] { new { Id = "int", PrimaryKey = true, Identity = true }, new { Email = "nvarchar(255)" } }).ExecuteNonQuery(); }; act = () => { person.Email = "*****@*****.**"; person.EmailConfirmation = "*****@*****.**"; }; it["requires the exclusion of confirmation properties"] = () => { persons.Insert(person.Exclude("EmailConfirmation")); var firstPerson = persons.All().First(); (firstPerson.Email as string).should_be(person.Email as string); }; }
private double TimeToRetrieve100kRowsFromOak() { start = DateTime.Now; var oakPeople = peoples.All().ToList(); oakPeople.Count.should_be(100000); finish = DateTime.Now; return(TotalSeconds(finish - start)); }
public int QuestionsEveryoneAnsweredYes() { var answerCount = 0; for (char c = 'a'; c <= 'z'; c++) { if (Persons.All(x => x.Answers.Contains(c, StringComparison.OrdinalIgnoreCase))) { answerCount++; } } return(answerCount); }
static void Main(string[] args) { //create your objects Person p = new Person(); p.Age = 35; p.Name = "Arnold"; Person p2 = new Person(); p2.Age = 36; p2.Name = "Tom"; Persons ps = new Persons(); ps.Add(p); ps.Add(p2); //Serialize them to XML XmlSerializer xs = new XmlSerializer(typeof(Persons)); XDocument d = new XDocument(); using (XmlWriter xw = d.CreateWriter()) xs.Serialize(xw, ps); //print xml //System.Diagnostics.Debug.WriteLine(d.ToString()); // it will produce following xml. You can save it to file. //I have saved it to variable xml for demo string xml = @"<ArrayOfPerson> <Person> <Age>35</Age> <Name>Arnold</Name> <XMLLine>0</XMLLine> </Person> <Person> <Age>36</Age> <Name>Tom</Name> <XMLLine>0</XMLLine> </Person> </ArrayOfPerson>"; XDocument xdoc = XDocument.Parse(xml, LoadOptions.SetLineInfo); // A little trick to get xml line xdoc.Descendants("Person").All(a => { a.SetElementValue("XMLLine", ((IXmlLineInfo)a).HasLineInfo() ? ((IXmlLineInfo)a).LineNumber : -1); return(true); }); //deserialize back to object Persons pplz = xs.Deserialize((xdoc.CreateReader())) as Persons; pplz.All(a => { Console.WriteLine(string.Format("Name {0} ,Age{1} ,Line number of object in XML File {2}", a.Name, a.Age, a.XMLLine)); return(true); }); Console.ReadLine(); }