in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

OBA, SharePoint and Aghy [MVP]

LINQ4SP - How to create a new item with a lookup to another list?

Well, how do you like our solution to query a list or insert a new item to a list by LINQ4SP? What do you think about it?

What would you tell, if I show you a newer interesting thing? Are you ready? - OK, today surprise is how to insert a lookup reference to another list. See this short demo, or check a piece of code here:

                // Create a new Category
                ProductCategory pc = new ProductCategory()
                {
                    Title = "new product category",
                };

                // Create a new Sub-Category item
                ProductSubcategory pcat = new ProductSubcategory()
                {
                    Title = "new sub category",
                    ProductCategory = pc
        // <<-- WOW! This is a lookup to Categories...
                };

                // Submit our new Sub-Category
                context.ProductCategory.InsertInSubmit(pc);
                context.ProductSubcategory.InsertOnSubmit(pcat);
                context.Submit();

So, how do you like it?...

Comments

 

OBA, SharePoint and Aghy [MVP] said:

Well, how do you like our solution to query a list or insert a new item to a list by LINQ4SP? What do

May 20, 2008 5:44 PM
 

Dew Drop - May 21, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - May 21, 2008 | Alvin Ashcraft's Morning Dew

May 21, 2008 8:10 AM
 

OBA, SharePoint and Aghy [MVP] said:

OK, let&#39;s play with LINQ4SP again. You can download Beta1 , write a simple query , create a new list

May 25, 2008 4:10 PM
 

SharePoint MVP Blogs said:

Well, how do you like our solution to query a list or insert a new item to a list by LINQ4SP? What do

June 19, 2008 10:02 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts