Why does this not work:
[OperationContract]
public List<Category> DoWork()
{
using(var db= new PDataContext())
{
return db.Categories.Select(x => x).ToList();
}
}
I get a CommunicationException error: Not Found.
But this does:
[OperationContract]
public List<myCategory> DoWork()
{
using(var db= new PDataContext())
{
return db.Categories.Select(x => new myCategory
{
CategoryID = x.CategoryID,
Name = x.Name,
Visible = x.Visible,
ParentID = x.ParentID
}).ToList();
}
}
public class myCategory
{
public int CategoryID { get; set; }
public string Name { get; set; }
public bool Visible { get; set; }
public int ParentID { get; set; }
}
I'm failing to understand how the LINQ2SQL Category class is in any way different than the code I wrote in the example above.
.Select(x => x)-- that doesn't do anything. Perhaps something is getting tripped up because of that.