Reputation: 2175
I am developing one mvc5 application with jquery. I am writing linq queries to access data from database. For example if i have the following model
public class employee
{
public string fname{get;set;}
public string lname{get;set;}
}
If i write below linq query to fetch data
var data=(from c in db.employee select c).to list();
For example i will get 3 rows of data as below.
fname lname
mike job
steve wagh
james anderson
In the above process i will pass data to view. If i want to have fname or lname in the encrypted format then how can I do these? Is there any way to convert it? I written class to encrypt a string with method called encrypt which takes one parameter. May i get some idea to achieve this. Thank you..
Upvotes: 0
Views: 397
Reputation: 3867
You can do it in your linq query as well like this
var data=(from c in db.employee select new Employee{ lname = encrypt(lname), fname = encrypt(fname)}).ToList();
Upvotes: 1