Created
May 28, 2013 23:12
-
-
Save bhameyie/5666861 to your computer and use it in GitHub Desktop.
query data with dynamic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
{ | |
public int Id { get; set; } | |
public int Age { get; set; } | |
public string Name { get; set; } | |
public Person() | |
{ | |
} | |
} | |
[TestFixture] | |
public class FunTest{ | |
[Test] | |
public void Retrieval_example(){ | |
var sqlBuilder = Database.Open().Persons.FindAllByName("li'l piggy"); | |
Assert.AreEqual("Select * from Persons Where Name = 'li''l piggy'", sqlBuilder.ToString()); | |
dynamic dynTable = new DynamicTable(dataTable); | |
var persons = new List<Person>(); | |
for (int i = 0; i < dynTable.Count; i++) | |
{ | |
persons.Add(dynTable[i].Convert<Person>()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment