Inloggen
 
 
 
 
    
Difference between Linq Objects and Linq Queries in a databinding scenario
Location: BlogsHenri Koppen - Developer    
Posted by: Henri Koppen 18-9-2008 10:31
I am currently developing an application using Linq in a databinding scenario. I like linq a lot being a set based command language, however some Linq/databinding behaviour is beyond me.
Tags: VB.NET Linq-to-SQL DataBinding.

I had to think some time to give this topic a title.

Look at this situation: I have a datagridview with a datasource property pointing to a bindingsource.

There's a difference between linking this datasource to a Linq-toSQL class and a Linq query.

Code:

Private db As New LinqDataContext

DataGridView1.DataSource = BindingSource1

' Situation A
BindingSource1.DataSource = db.Users

' Situation B
BindingSource1.DataSource = FROM u IN db.Users



If I delete an user in Situation A like this :
Code:

db.Users.DeleteOnSubmit(BindingSource1.Current)
db.SubmitChanges()
BindingSource1.DataSource = db.Users



The user will not dissappear immediately.

If I delete an user in Situation B like this
Code:

db.Users.DeleteOnSubmit(BindingSource1.Current)
db.SubmitChanges()
BindingSource1.DataSource = FROM u IN db.Users



The gridview is updated and will not show the deleted user.

I think that the difference is this: If you use a LINQ query it query's the database. If you just show the objects it looks into the object collection.

If you inspect the datasource of the bindingsource in debug mode you see that (when using a linq query) that the type is a "Database query", while db.Users as datasource is a Linq.Table (of users).

It has something to do with a bindingsource keeping it's own "administration".

Permalink |  Trackback

Comments (7)   Add Comment
Coach Handbags    By Coach Handbags on 16-7-2010 7:29
utopia
With Coach Handbags of styles and colors to choose from you really can’t go wrong.The heels collection provides everything from the big hit of the season ankle boots, to strappy Nike Air Jordan.After hitting the market in 2004, Tory Burch Cheap Gucci Shoes have become a fashion essential for those looking for the latest in style and surprisingly comfort. Michael Jordan Shoescome in a wide range of variety and styles. The big portion of their market and nike dunk appeal comes from their collection of flats that not only is trendy but is known for their wear ability and comfort.With a wide range of designers and Nike Air Jordan on the market, these fashionista savvy Cheap MBT Shoes can come off the cover of Elle magazine without breaking the bank.

wow gold    By cqx on 16-7-2010 11:13
It is the wow gold true test wow goldof how wow gold human we cheap wow goldreally are. buy wow goldHow much we buy cheap wow goldcan accept in buy wow gold cheapour fellow humans. wow gold cheapAnd reallycheapest wow gold ever how much we wow buy goldwant to accept. cheap wow goldIf we acceptwow gold sale too much does buying wow goldthat make wow power levelus strong. wow gold guide And if we wow gold cheapdon't accept gold for wow enough does thatwow gold prices make us weak.wow gold hacks Or is it make wow goldthe other way wow power levelingaround All these wow powerlevelingthings are a wow cd keytrue test wow goldof how muchcheap wow gold you are capablewow gold of loving We allwow gold cheap are born into this world with one shall love and be loved.

wow gold    By cqx on 16-7-2010 11:14
It is the wow gold true test wow goldof how wow gold human we cheap wow goldreally are. buy wow goldHow much we buy cheap wow goldcan accept in buy wow gold cheapour fellow humans. wow gold cheapAnd reallycheapest wow gold ever how much we wow buy goldwant to accept. cheap wow goldIf we acceptwow gold sale too much does buying wow goldthat make

Betr: Difference between Linq Objects and Linq Queries in a databinding scenario    By qyy on 23-7-2010 7:50
I think that the difference is this: If you use a LINQ query it query's the database. If you just show the objects it looks into the object collection.
_____________________________________________________________________________

true religion mens jeans/2010 links of london/louis vuitton watches/charms

schmuck/true religion jeans sale/thomas sabo charm/ed hardy shirts

true religion jeans sale/true religion jeans/links of london watches/cheap true religion jeans

Betr: Difference between Linq Objects and Linq Queries in a databinding scenario    By asdf on 23-7-2010 9:00
wholesale nike shoes

wholesale nike running shoes

wholesale nike basketball shoes

wholesale shoes

wholesale jordan shoes

wholesale dunk shoes

wholesale adidas shoes

SEO

Ugg boots

Us Ugg boots

外贸SEO

Sheepskin Ugg Boots

Ugg Boots

Emu Sheepskin Ugg Boots

Ugg Boots Sale

Cheap Ugg Boots

Ugg Boots

GHD UK

GHD

GHD Straighteners

GHD Hair Straighteners

GHD South Africa

GHD Hair Products

GHD

GHD Straighteners UK

GHD Hair UK

GHD

MBT USA

MBT

MBT Shoes

Cheap MBT Shoes

Discount MBT Shoes

MBT Shoes

swiss replica watches

replica chanel watch

replica ceramic watches

cheap swiss replica watches

Swiss Replica Watches

Replica Watches

cheap Swiss Watches




nothing is impossible···    By anlia on 26-7-2010 2:55
Thanks for your sharing, good job!
Are you interested in the gucci outlet series? Topguccishoes.com will be the right place that you have come to. There are many different kinds products of discount gucci shoes for your selection, including gucci handbags, gucci sneakers which content with gucci men shoes, gucci jeans, Gucci Skirt, gucci bikini , gucci belts, Gucci Spicy Underwear, Gucci Wallets, Gucci Jewelry, gucci hats, gucci sunglasses and Women Gucci boots line. Welcome to the discount gucci handbags as well as ugg bailey button boots and buy gucci with the best quality at affordable price.

cheap ugg boot store    By ugg australia on 29-7-2010 4:40
Not even as I shook womens ugg boots and trembled uncontrollably in the trenches, did I forget your ugg boots face. I would sit huddled into the wet mud, terrified, as the ugg australia hails of bullets and mortars crashed down around me. I would clutch my uggs bailey button rifle tightly to my heart, and think again of that very first day we met. I would cry out in bailey button boots fear, as the noise of war beat down around me. But, as I thought ugg boots in uk of you and saw you smiling back at me, everything ugg boots usa around me would be become silent, and I would be with you again for a few precious official ugg boots moments, far from the death and destruction. It would not be ugg classic cardy until I opened my eyes once again, that I would see and hear the carnage of the war around me.I cannot tell you ugg classic cardy boots how strong my love for you was back then, when I returned to you on leave in the September, feeling uggs classic cardy battered, bruised and fragile. We held each other so tight I thought ugg uk we would burst.


Your name:
Title:
Comment:
Add Comment   Cancel 
  
 
Weblogs
    
Archief
    
Zoeken
    
 
 
 
 
Copyright 2006-2009 by Arcencus
Privacy Statement | Terms Of Use