G
Guest
Is it possible to call another method out of the select statement?
In this example I am trying to call GetItem() from within the first select
statement.
But I get the following error"
"Method 'GetItem(MyDataContext, System.Guid, Boolean)' has no supported
translation to SQL."
public static List<Item> GetProducts(Guid customerID)
{
List<Item> services = new List<Item>();
using (MyDataContext dc = new MyDataContext(connectionString))
{
var q = from p in dc.Products
select GetItem(dc, p.ServiceID, Convert.ToBoolean(p.IsKit));
return q.ToList();
}
}
private static Item GetItem(ProductServiceDataContext dc, Guid serviceID,
bool isKit)
{
if (isKit)
{
var q = from p in dc.Products
where p.ServiceID == serviceID
select new Service(...) // Service is a derivative of Item
return q.First();
);
...
}
This seems like it should be legal.
In this example I am trying to call GetItem() from within the first select
statement.
But I get the following error"
"Method 'GetItem(MyDataContext, System.Guid, Boolean)' has no supported
translation to SQL."
public static List<Item> GetProducts(Guid customerID)
{
List<Item> services = new List<Item>();
using (MyDataContext dc = new MyDataContext(connectionString))
{
var q = from p in dc.Products
select GetItem(dc, p.ServiceID, Convert.ToBoolean(p.IsKit));
return q.ToList();
}
}
private static Item GetItem(ProductServiceDataContext dc, Guid serviceID,
bool isKit)
{
if (isKit)
{
var q = from p in dc.Products
where p.ServiceID == serviceID
select new Service(...) // Service is a derivative of Item
return q.First();
);
...
}
This seems like it should be legal.