i know that Linq to entities does not support parametrized constructors, but how to do this pls ?:
date = new DateTime(int.Parse(SqlFunctions.StringConvert(l.rok).Trim()), int.Parse(SqlFunctions.StringConvert(l.mesic).Trim()), 1)
Whole example:
var objects = from object in GetObjects()
select new MyObject{
name = object.name;
date = new DateTime(object.rok,object.month,object.day)
}
How to do this?
Use the EntityFunctions CreateDateTime method found here: http://msdn.microsoft.com/en-us/library/system.data.objects.entityfunctions.createdatetime
These helper methods were built to translate to a SQL equivalent, as noted in the remarks of that link:
You cannot call this function directly. This function can only appear within a LINQ to Entities query.
This function is translated to a corresponding function in the database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With