Not Supported Exception was Unhandled

Asked By lavanya r
31-Aug-10 02:33 PM
Earn up to 0 extra points for answering this tough question.

Hi

I am trying to execute following Linq query 

var x = from d in obj.PG_PAYMENT_TRANSACTIONS

                        from a in obj.PG_CONTRACT_MASTER

                        where (d.CREATED_DATE.Date) == (DateTime.Now.Date) && d.CONTRACT_ABBR == a.CONTRACT

                        select new { d.TRANSACTION_ID };

                foreach (var item in x)

                {     Getting Error Here Saying that              

               }

The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

Any Idea,
Lavanya

  re: Not Supported Exception was Unhandled

Peter Bromberg replied to lavanya r
31-Aug-10 03:39 PM
Are you sure that d.CREATED_DATE.Date shoudn't be d.CREATED_DATE  ?

  re: Not Supported Exception was Unhandled

lavanya r replied to Peter Bromberg
01-Sep-10 10:39 AM
Yes,

You are right, i am able to solve this by creating a  field before using in linq. Not sure why it is giving runtime exception using directly DateTime.Now.Date. 

static DateTime today = DateTime.Now.Date;
 var x = from a in obj.PG_PAYMENT_TRANSACTIONS
                        from b in obj.PG_CONTRACT_MASTER
                        where (a.CREATED_DATE) > today && a.CONTRACT_ABBR == b.CONTRACT
                        select new {  };

Thanks 
Lavanya
Create New Account