Bringing it all together: Even More Magic,
So, I had done a couple of fairly cool stuff recently, but it is all in seperated pieces, let us try to bring them together and see what we get, shall we?
ProjectionQuery<User> query =
new ProjectionQuery<User>(Where.User.Name.Like("Ayende", MatchMode.Start),
ProjectBy.User.Name && ProjectBy.User.Email);
foreach (object[] objects in query.Execute())
{
Console.WriteLine("Name: {0}, Email: {1}", objects[0], objects[1]);
}
That is nice, isn't it? Again, we can use the strongly typed version to be type safe and avoid the use of arrays as DTO:
ProjectionQuery<User, NameAndEmail> query2 =new ProjectionQuery<User, NameAndEmail>(
Where.User.Name.Like("Ayende", MatchMode.Start),
ProjectBy.User.Name && ProjectBy.User.Email);
foreach (NameAndEmail nameAndEmail in query2.Execute())
{
Console.WriteLine("Name: {0}, Email: {1}", nameAndEmail.Name, nameAndEmail.Email);
}
And yes, this is filed under Linq as well.
Comments
Comment preview