Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

Update to LINQ to SQL Business Object Wrapper Sample


:P
On this page:

Last night I after I posted the LINQ DataContext post I realized that I hadn't ever updated the LINQ Business Object Layer example app for .NET 3.5 RTM. Although I've long updated the code, since I use it here in a few internal applications as a base business object wrapper around LINQ to SQL, I hadn't updated the live examples since DevConnections last year. Ooops. This is what happens when I have too much code floating around online - I forget what's up to date and what isn't...

To recap the download includes a small ASP.NET 3.5 Time Tracking sample application which is built around this wwBusinessObject implementation. The TimeTrakker project includes a separate and reusable business object framework project which includes the business object base, an extended DataContext that also provides raw ADO.NET access so DataContext can act as a mini DAL even outside of LINQ based entity queries. I know this kind of sounds like blasphemy but it's come in handy in a few situations (serialization problems with LINQ Entities - able to pass a DataTable for example, or running queries that are way more complex to code with LINQ that as a raw SQL query) as well as taking LINQ queries and grabbing Command objects from them for manual command execution (which is a pretty cool feature of L2S actually).The DataContextFactory I mentioned yesterday also is part of this library.

No rocket science here, but I've been using this light framework in a couple of internal projects here and it's working out really well for me. There might be some useful ideas for others to check out and play wiht.

You can find out more about what's in the Business Object Wrapper from the original post. Note the post's code is Beta 2 so there are a few changes required, but the code in the download is up to date:

A simple Business Object Wrapper for LINQ to SQL

Download:

Simple Business Object Wrapper Source and Sample Application

Hope this is useful to some of you.

Posted in LINQ  

The Voices of Reason


 

Brian Orrell
February 09, 2008

# re: Update to LINQ to SQL Business Object Wrapper Sample

Rick, I posted an entry on dealing with the nuances of using ASP.NET with LINQ and how to attach disconnected entities back to the context. I would be interested in your feedback.

http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html

Thanks

Nagarajan
March 15, 2008

# re: Update to LINQ to SQL Business Object Wrapper Sample

Hi Rick,
I am getting this error "The type or namespace name 'TimeTrakkerBaseForm' could not be found", but this class is available in folder "Classes" , please help me in this

Thanks,
Nagarajan.

Rick Strahl
March 15, 2008

# re: Update to LINQ to SQL Business Object Wrapper Sample

You need to use Visual Studio 2008 not Visual Web Developer. This project uses Web Application Projects so it can't be opened as a file based Web project.

Adrian Grigore
April 19, 2008

# re: Update to LINQ to SQL Business Object Wrapper Sample

Rick,

Thanks very much for the update! Judging by the original posting, your framework looks great and I'm probably going to use it in my next project.

Thanks again,

Adrian

Sudheer Kumar
June 19, 2008

# re: Update to LINQ to SQL Business Object Wrapper Sample

Rick,
The framework looks great..!
Do you have the DB Schema for the sample you created for download.
Thanks..Sudheer

LurkingVariable
March 28, 2009

# re: Update to LINQ to SQL Business Object Wrapper Sample

Hey Rick, I'm just tearing into this now, thanks! Any updates to the code since this one from over a year ago?

-LV

Rick Strahl
March 28, 2009

# re: Update to LINQ to SQL Business Object Wrapper Sample

@lurkingVariable - the code's been updated a few times.

It's also been rolled into the (still under construction) West Wind Web Toolkit:
http://www.west-wind.com/WestwindWebToolkit/

for easier access to changes and fixes in the code repository.

Monty
April 05, 2009

# re: Update to LINQ to SQL Business Object Wrapper Sample

Hi Rick, does the business framework you've created allow for a collection of Business Objects to be edited and saved as a group? For instance, with straight linq entities I could set my WinForm grid's binding source like so:

ProductsBindingSource.DataSource = From pb In DC.Products Order By P.Name

Then do some editing on the products in the grid, add a few new products to the grid, then call DC.SubmitChanges and be good to go. Now if I want to use the business object wrapper for the Product entity, is it possible to bind a collection of the BO wrappers to a grid and have it act similarly to the above example?

Thanks man. This framework is VERY cool.

Monty

PS - I've ported the framework to VB.Net. Mind if I post the translation on my (as yet non-extant) blog? Giving full credit and links, of course.

Rick Strahl
April 05, 2009

# re: Update to LINQ to SQL Business Object Wrapper Sample

@Monty - sure the framework is just a very thin wrapper around Linq to SQL and all the same semantics of saving should work when calling .Save().

re: Porting. As long as you provide a link back and credit that's Ok by me. You can post the link here.

Matt S
February 05, 2010

# re: Update to LINQ to SQL Business Object Wrapper Sample

Has anyone ported this to Entity Framework as of yet? I would be very interested to take a look at that.

Konda reddy
March 09, 2010

# re: Update to LINQ to SQL Business Object Wrapper Sample

Good posting ricky

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024