Column Value Converters are not fired when using coalesce operator in a query
See original GitHub issueGood day, Recently I noticed a bug in either this library or in the Linq2Db query engine itself - I am not sure where exactly. The issue is that when defining a custom value converter in EF Core db context (for nullable DateTime in my particular case) they are not being fired when a query is using coalesce operator. However in pure EF Core they work just fine.
Here is a sample query:
using var context = container.GetService<SampleDataContext>();
var query = from t2 in context.TableTwo
join t1 in context.TableOne on t2.TableOneId equals t1.Id into t1j
from t1 in t1j.DefaultIfEmpty()
select new
{
t2.Code,
NullableDateColumn = t2.NullableDateColumn, //here the converter is launched properly
FromDate = t1.FromDate ?? t2.FromDate, //here the converter is not launched
ToDate = t1.ToDate ?? t2.ToDate, //here the converter is not launched
};
var results = query.ToLinqToDB().ToList();
I have also attached a full sample project with two Nunit tests where the issue can be easily reproduced and they use the above query: Linq2DbDateConvertersBug.zip The test named TestEFCore passes however the test named TestLinq2Db fails - they both use the same logic and query so they should both pass.
I use Linq2Db together with EF Core in many projects and for me this synergy is just awesome, however because of this bug I recently have quite a lot of headaches. I noticed this for datetimes with relation to coalesce operator, however I think this bug can be affecting also other types of converters and operators as well.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
I have checked this particular case works.
I have checked the newest release of Linq2Db 4.1.1 and I confirm all mentioned here issues are resolved. I am closing the issue as a result. Thanks for fixing this!