Reputation: 12763
i am making wcf rest service using linq. i wanna use stored procedure to access the database in linq..i came to know to about the accessing syntax but ToList() property i m not finding in my project..can anybody suggest me the solution ?
Code : [OperationContract] [WebGet(UriTemplate = "/CList/")] public CList[] GetCList() {string strConnection = ConfigurationManager.ConnectionStrings["HConnectionString"].ConnectionString;
HDataContext dc = new HDataContext(strConnection);
string strUrl = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.ToString();
var result = from cust in dc.tbl_Customer_Masters
select new CList
{
RMSID = 0,
CID = cust.C_Id,
FIRSTNAME = cust.C_First_Name,
LASTNAME = cust.C_Last_Name,
};
return result.ToArray(); }
Upvotes: 0
Views: 261
Reputation: 19635
The ToList()
method is only defined for objects that inherit from System.Linq.Enumerable
or that implement the IEnumerable
interface. So, you need to make sure of the following:
System.Linq
namespace in your file.ToList
on actually inherits from System.Linq.Enumerable
or implements the IEnumerable
interface.Upvotes: 1
Reputation: 27115
ToList is an Extension Method. This means it's not actually in the containing class. You need to add a using statement to your code to use this feature.
using System.Linq;
Then you can call ToList() on any IEnumerable
Upvotes: 0