I have a question about working with DB using Liqn to SQL.
I have a little database, which includes 4 tables and I have Liq to SQL classes created for this tables:
So, It's all created on my AppName.Web project. I'm also created a WPF Service, that returns List collection with all Entries inside.
When I just tried to call my function from Silverlight project I've got CommunicationException. I've tried to set
maxReceivedMessageSize
and maxBufferSize
, but problem still appeared. Than I add [DataContract]
and [DataMember]
tags to auto-generated classes (except properties, that represents references, like Items
in Mod
table, Recipes
and Entries
in Item
table, etc.) and it started to work, but I can receive only data from one table.
How can I receive List of Mods with all childs in all tables? And is linq to sql one of the best and easiest ways to do it?
UPD1: Functions to return List:
public MCDataClassesDataContext GetContext()
{
var context = new MCDataClassesDataContext();
var dlo = new DataLoadOptions();
dlo.LoadWith<Mod>(p => p.Item);
dlo.LoadWith<Item>(p => p.Recipe);
dlo.LoadWith<Item>(p => p.Entry);
dlo.LoadWith<Recipe>(p => p.Entry);
context.LoadOptions = dlo;
return context;
}
public List<Mod> GetMods()
{
return GetContext().Mod.ToList();
}