0

I have Entity Framework version greater than 6 as can be seen below and I am getting an error

DbArithmeticExpression arguments must have a numeric common type

enter image description here

The below LINQ query is generating error when I subtract two dates I think

var dateee = DateTime.Now.AddDays(30);

List<Account> account = webUOW.RepoOf<Account>()
            .Get(q => q.Active == true && 
                      q.GotFriendListDate != null &&  
                      (dateee - q.GotFriendListDate.Value).Days > 30)
            .ToList();
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kinnan Nawaz
  • 399
  • 2
  • 7
  • 24
  • Does this help? https://stackoverflow.com/questions/9820401/dbarithmeticexpression-arguments-must-have-a-numeric-common-type – DavidG Mar 06 '23 at 17:39
  • @DavidG Yes i looked at it and that is why I am saying i have entity framework version greater than 6 as can be seen in the question – Kinnan Nawaz Mar 06 '23 at 17:41
  • 3
    6.4.4 is still 6, that question is still valid. – DavidG Mar 06 '23 at 17:52
  • @DavidG I have the latest EF version 6.4,4, I have to upgrade to EFCore after EF 6.4.4, I think it is (subtracting dates) not working for the EF 6.4.4 also – Kinnan Nawaz Mar 06 '23 at 18:03
  • 1
    You are not making sense I'm afraid. Are you sure you can upgrade to EF Core? If you are running .NET Framework 4.x, then you are stuck with EF 6.x. The subtraction of dates as shown in the question I linked above absolutely DOES work for EF 6.4.4. You should try it instead of pushing back. – DavidG Mar 06 '23 at 18:28
  • @DavidG No i am not upgrading to EFCore i am stuck with EF 6.4.4 and i think that the link you shared in the first comment is valid for EF version 6.4.4 also, it trows error when i subtract dates in EF version 6.4.4 the above link in your comment is I think the answer i am going for thanks – Kinnan Nawaz Mar 07 '23 at 07:47

0 Answers0