How to change data from anonymous request in EntityFramework

I am using Entity Framework and I have table users and the row with data to be decrypted, the problem is when I make a query to list these users, I cannot decrypt directly, is an anonymous type ..

 var query = context.Users.Where(x => x.Id == id).Select(x => new
 {
    x.Id,
    x.FirstName,
    x.LastName,
    x.UCP
 });
 response = Request.CreateResponse(HttpStatusCode.OK, query.ToList());

      

So how to change data from UCP to decrypted data, I am not asking how to decrypt, but how to change!

+3


source to share


1 answer


var query = context.Users.Where(x => x.Id == id).Select(x => new
                {
                    x.Id,
                    x.FirstName,
                    x.LastName,
                    x.UCP
                })
                .AsEnumerable()
                .Select(x => new
                {
                    x.Id,
                    x.FirstName,
                    x.LastName,
                    UCP = Decode(x.UCP)
                });
                response = Request.CreateResponse(HttpStatusCode.OK, query.ToList());

      



AsEnumerable

better than ToList

, it doesn't create collections

+2


source







All Articles