Linq DataContext

Posts   
 
    
MattE avatar
MattE
User
Posts: 77
Joined: 11-Sep-2007
# Posted on: 24-Dec-2008 10:54:08   

Hi there,

A number of Linq operations seem to require a Linq to SQL data context


Northwnd db = new Northwnd(@"c:\Northwnd.mdf");

// Query for a specific customer.
var cust =
    (from c in db.Customers
     where c.CustomerID == "ALFKI"
     select c).First();

// Change the name of the contact.
cust.ContactName = "New Contact";

// Create and add a new Order to the Orders collection.
Order ord = new Order { OrderDate = DateTime.Now };
cust.Orders.Add(ord);

// Delete an existing Order.
Order ord0 = cust.Orders[0];

// Removing it from the table also removes it from the Customer’s list.
db.Orders.DeleteOnSubmit(ord0);

// Ask the DataContext to save all the changes.
db.SubmitChanges();

Does Linq to Llblgen emulate this functionality in some way?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 24-Dec-2008 18:04:10   

LLBLGen Pro implements linq in Full through its own IQuerayble<T> interface implementation. See the v2.6 documentation about the Linq provider.

Frans Bouma | Lead developer LLBLGen Pro
MattE avatar
MattE
User
Posts: 77
Joined: 11-Sep-2007
# Posted on: 29-Dec-2008 08:29:03   

Hi Frans,

Thanks - yes, I am aware of the LingMetaData class and its usage, what I am wondering about is the use (as in the code snippet above) of the DataContext classes generated when creating Linq to Sql classes in Visual Studio...

Regards,

Matthew

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 29-Dec-2008 10:20:55   

MattE wrote:

Hi Frans,

Thanks - yes, I am aware of the LingMetaData class and its usage, what I am wondering about is the use (as in the code snippet above) of the DataContext classes generated when creating Linq to Sql classes in Visual Studio...

Regards,

Matthew

I'm not sure why you're asking here on the llblgen pro forums what the Datacontext is of linq to sql? It's in the MSDN documentation about linq to sql.

LLBLGen Pro doesn't use a central 'session/context' class as most o/r mappers do, perhaps that's the reason for your question. The classic Scott Ambler design of an o/r mapper uses a central session/context class which does all the persistence logic and contains all the fetched entities. In llblgen pro there's no such thing.

Frans Bouma | Lead developer LLBLGen Pro
MattE avatar
MattE
User
Posts: 77
Joined: 11-Sep-2007
# Posted on: 02-Jan-2009 14:38:52   

10-4. Understood..