I have a stored procedure which returns all the fields of a table plus one, ie:
tablename.*,count(suchandsuch)
Of course, when executing this via LINQs ExecuteQuery I can get back instances of the table's class in an IEnumerable<>, but I also want the extra field which the stored proc tacks on.
Is this possible?
My current code looks like this:
public class CategoryWithInstanceCount : DataAccess.Category
{
[System.Data.Linq.Mapping.Column(Storage = "_Instances", DbType = "Int NOT NULL")]
public int Instances { get; set; }
}
protected IEnumerable<CategoryWithInstanceCount> GetCategories(int? parentid)
{
PriceDataContext context = new PriceDataContext(ConfigurationManager.ConnectionStrings["connStr"].ConnectionString);
IEnumerable<CategoryWithInstanceCount> ie = context.ExecuteQuery<CategoryWithInstanceCount>(
String.Format("EXEC [dbo].[GetCategoryFromParentID] @parentcategoryid = {0}", parentid == null ? "NULL" : parentid.ToString())
);
return ie;
}