2

I am using LINQ to query on a set created using EF Code First.

The code below produces an ArgumentException with the message "DbArithmeticExpression arguments must have a numeric common type."

var result = set.Any(item => item.val);

// where set is a DBSet<mytype> and mytype.val is a bool.

Jacob


Added after comments:

The original query is:

var set = table.where(item => DateTime.Now() < item.date + item.interval);

// where .date is a DateTime and .interval is a Timespan

Jacob

Jacob
  • 453
  • 5
  • 17
  • 1
    The problem may be how you define `set`; you just aren't seeing it until you actually execute it by calling `.Any()`. Does `set` have a `Where` clause? Ususally the problem is a date filter that EF can't directly translate to SQL. – D Stanley May 07 '13 at 15:38
  • @D Stanley Yes there is a date filter. Any suggestion how to resolve it? – Jacob May 07 '13 at 16:08
  • I suggest you post the query that includes the filter. – D Stanley May 07 '13 at 16:10
  • it is: var set = table.where(item => DateTime.Now() < item.date + item.interval); // where .date is a DateTime and .interval is a Timespan – Jacob May 07 '13 at 16:19
  • Please add it to your question to get better formatting. – D Stanley May 07 '13 at 16:21
  • 1
    If you google the error message the first result gives you a likely answer. – D Stanley May 07 '13 at 16:22

0 Answers0