Tom Kong
Tom Kong

Reputation: 5

Linq to SQL query error

public class Service1 : IService1
{
    [OperationContract]
    public List<decmal> GetEnterCounts(DateTime StartTime, DateTime EndTime)
    {
        var db = new FACT_ENTER_EXIT();
        return (from e in **db.ENTER_CNT** where StartTime < db.DATE_ID && db.DATE_ID > EndTime select e).ToList();
    }
}

Ok, so I have this database FACT_ENTER_EXIT containing the field ENTER_CNT (nullable = false, type = decimal) which I want to return as a list

VS2010 spits out the following error at 'db.ENTER_CNT':

Error 1 Could not find an implementation of the query pattern for source type 'decimal'. 'Where' not found.

I must be missing something, could someone please point out where I'm going wrong??

Thanks in advance, Tom

Upvotes: 0

Views: 145

Answers (1)

lc.
lc.

Reputation: 116528

You want to select from the table, not from a column, then select from your column.

Try:

from e in db.MyTable
where StartTime < e.DATE_ID && e.DATE_ID > EndTime
select e.ENTER_CNT

This resembles the following SQL:

SELECT e.ENTER_CNT
FROM MyTable e
WHERE @StartTime < e.DATE_ID AND e.DATE_ID > @EndTime

Upvotes: 2

Related Questions