I have the following query:
from a in Products
select new ProductVM
{
id = a.id,
modified = a.modified.ToString()
}
Create a new POCO with this structure (I'm assuming that the data type is DateTime):
public class UserProductVM {
...
private DateTime _modified;
public DateTime SetModified { set { _dateEvent = value; } }
public string Modified { get { return _modified.ToString("dd MMM yyyy @ HH:mm:ss"); } }
...
}
Then you assign the value to SetModified, changing your code like this:
from a in Products
select new UserProductVM
{
...
SetModified = a.modified
}
Pay attention i'm using UserProductVM instead ProductVM and SetModified instead modified.
Then when you get the property Modified, the new POCO is gonna bring it as the string that you formatted.