I have a stored procedure that returns all the fields of a table plus one, that is:
tablename.*,count(suchandsuch)
Of course, when doing this through LINQs ExecuteQuery, I can return the table class instances to IEnumerable <>, but I also need an extra field that stores the stored proc.
Is it possible?
My current code is as follows:
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;
}
source
share