Screencast: Working with Views in LightSpeed
Yet another how-to screencast on working with LightSpeed, we have just published “Views with LightSpeed”.
LightSpeed has always supported working with Views however with LightSpeed 2.2 we have added many enhancements to make them easier to work with. This video helps explore what new additions have been made to improve the developer experience when working with views.
With this screencast you will learn:
- How to easily work with views in the LightSpeed Visual Studio Designer
- How to query against views – both with the generated IQueryable
and the LightSpeed classic query API - How to deal with views that are projections of tables rather than matching existing entities
- How to with views that return projections that do not match existing entities
- When having an updatable view would be useful.
Click here to watch how to use Views with LightSpeed.
We added improved view support to LightSpeed for version 2.2 (and in the nightly builds following 2.1). Grab a copy of the latest build of LightSpeed that includes this support here.
Any feedback – either on the view support of on the screencast itself, is greatly appreciated. Drop a comment on this post.
2 Responses to “Screencast: Working with Views in LightSpeed”
Leave a Reply
![]()
BrainDump (1)
Community Code (1)
Events (6)
General (31)
Lab Samples (2)
LightSpeed (132)
MegaPack (3)
News (48)
Products (64)
Projects (4)
Screencast (6)
SharePoint (1)
Silverlight (5)
Silverlight Elements (12)
SimpleDB Management Tools (11)
Visual Studio (4)
VS File Explorer (5)
WPF (31)
WPF Diagramming (14)
WPF Elements (22)
WPF Property Grid (24)
![]()
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007



Tagged as 

Posted by John-Daniel Trask on 27 January 2009



Great!
Keep them comming, more complicated video sessions welcomed, or is everything so purely easy with LightSpeed? ;)
1. “obviously we can/cannot update the sku table” at 6:50 timeframe.
So Can we or can’t we? Sometimes the voice is really hard to comprehend for non-english speakers, different voice would be welcomed (any lady out there?;-)
2. I’ve got quick question at the ending:
When I’ve changed just the SkuCode type will Lightspeed save changes upon UOW commit to both SKU entity and SkuCodes View or just the View? What about concurency problems (someone updated Code in SKU table and another one on SkuCode entity)?
3. Watching last video and this one I have one really newbie question:
What is the difference between using View CheapItems and making a Stored procedure to return them.
As I understand it, using View I’ll automatically get
collection of strongly typed LS entities and which is LINQified (IQueryable) so it is very easy to work with, but views are mostly static.
Whereas using Stored Procedure I’ll just get an IList collection (and I can use parameters) but I have to call AsQueryable() extension method on it to use it with LINQ.
4. in the video, couldn’t you just use LINQ to return entity with “ProductID” == 1? Or is it faster to work with IList and you’ve choosed not to have overhead of IQueryable interface?
Thank you
Hello Nefajciar,
If you change a SkuCode entity and save changes, it will get saved back to the SkuCodes “table” — which is actually a view. Of course this will only work if it is an updateable view. And you are correct that this could cause concurrency issues if you load both a SkuCode and a Sku, and save one of them back. LightSpeed doesn’t know that SkuCodes and Skus are related. So the scenario shown in the video is a bit artificial — in reality you would probably not have read-write entities which “overlap” in this way, but we wanted to keep the model simple for the video.
Notice, by the way, that this issue only arises because Sku and SkuCode are different *types*. Skus loaded through different views — e.g. CheapItems and ExpensiveItems — are identified and participate in normal entity concurrency behaviour. So there are actually two different kinds of view support in LightSpeed — views as a way of creating new entity types (SkuCodes), and views as a way of querying existing entity types (CheapItems).
Regarding the differences between making a view for CheapItems and making a stored procedure for CheapItems: one obvious difference is that a stored procedure can take parameters, e.g. GetCheapItems(decimal maxPrice). Also, a stored procedure can contain a lot more business logic than a view. But a stored procedure is not queryable: for example you can combine a view with a WHERE clause but you cannot do the same with a stored procedure. (This is why the designer-generated wrappers for stored procedures return ILists and those for views return IQueryables.) You can still use sproc return sets with LINQ but this will use LINQ to Objects and be processed client-side.
The video shows both LINQ-based and Find-based techniques for using views. So using LINQ you can go uow.CheapItems.Where(sku => sku.ProductId == 1) and using Find you can go uow.Find(new Query(Entity.Attribute(“ProductId” == 1) { ViewName = “CheapItems” }). Either is good; it’s a matter of taste (and which version of the .NET Framework you’re targeting) which you use.
I’ll let JD field the questions about vocal technique since he’s the star of the show…