using (AdventureWorksEntities advWorksContext = new AdventureWorksEntities())
{
string esqlQuery = @"SELECT contactID, AVG(order.TotalDue)
FROM AdventureWorksEntities.SalesOrderHeader
AS order GROUP BY order.Contact.ContactID as contactID";
/* Your Query, In Your Query there is error
string squery = @"select MMetric.UId,UMA.AName,MMetric.Date,AModules.MName from MMetric, UMA, AModules where
MMetric.AID=UMA.AID and UMA.AID= MMetric.AID and AModules.MID=MMetric.MID"
UMA.AID= MMetric.AID This Line You Write Two Time. Si It May Be "UMA.UID=MMetric.UID"
*/
try
{
foreach (DbDataRecord rec in
new ObjectQuery<DbDataRecord>(esqlQuery, advWorksContext))
{
Console.WriteLine("ContactID = {0} Average TotalDue = {1} ",
rec[0], rec[1]);
}
}
catch (EntityException ex)
{
Console.WriteLine(ex.ToString());
}
catch (InvalidOperationException ex)
{
Console.WriteLine(ex.ToString());
}
}
//I Hope This Will Help You.....