Hello Guys, I hope you are all doing fine. I have a Linq to SQL problem.
My entity class is as follows;
using System;
using System.Data.Linq;
using System.Data.Linq.Mapping;
namespace SilverlightGrid.Web.TableMappings
{
[Table(Name = "Travel_Meal")]
public class Travel_MealDetails
{
[Column(IsPrimaryKey = true)]
public Guid MealID { get; set; }
[Column(Name = "Meal_Desc")]
public String MealType { get; set; }
}
}
It works fine but I get an error when I query data like so:
public List<Travel_MealDetails> getMeals()
{
Settings db3 = new Settings();
// DataClasses1DataContext db = new DataClasses1DataContext("NucleusConnectionString");
DataContext db2 = new DataContext(db3.DBConnect);
Table<Travel_MealDetails> meals = db2.GetTable<Travel_MealDetails>();
var persons = (from c in meals
select new Travel_MealDetails
{
MealType = c.MealType,
MealID = c.MealID
}).ToList();
return persons.ToList();
}
It throws an error saying:
Explicit construction of entity type 'SilverlightGrid.Web.TableMappings.Travel_MealDetails' in query is not allowed.
I hope someone can help me TIA.