Extract information from Func <bool, T> or similar lambda
I am trying to create a general cache level. ICacheRepository
Say I have the following:
public class Person
{
public int PersonId { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
public DateTime Added { get; set; }
}
And I have something like this:
list.Where(x => x.Firstname == "Syska");
Here I want to extract the above information in order to check if the "PersonId" query has provided, which it does not have, so I do not want to cache it.
But I will say that I run this request:
list.Where(x => x.PersonId == 10);
Since PersonId is my key ... I want to cache it. with a key like "Person_10", and later I can extract it from the cache.
I know that you can extract information using Expression<Func<>>, but there seems to be a lot of overhead for this (when starting compilation and extracting Constant values, etc. and a bunch of cache to make sure the analysis is correct)
? - / ?
:
EF Code First CTP5.
, .
, :
repository.SingleOrDefault(x => x.Email == "some@legel.mail");
- - "", , , " ".
Expression<Func<User, bool>> b;
b.Body // Here I can extract most information without compiling it, to fetch what its being quried for.
, , , , , SQL . , .
BinaryExpression.... . .
, EF Code First.
, Expression<Func<bool, T>>. ( ), , . , ORM, LINQ-to-SQL Entity Framework, (LINQ-to-SQL SQL, Entity Framework EntitySQL ..).
.
IQueryable<T>. , LINQ ( ).Where,Expression<Func<bool, T>>.
. , , .
, MSDN . , . , , !