Friday, July 03, 2009
#
Dave McCarter has released a great package of Tips and Helpers.
After lots new coding, refactoring and upgrading to .NET 3.5, dotNetTips.Utility 3.5 is finally released! This assembly is much of the common code I have been writing for the past 8+ years all wrapped up in a nice package and easy to use.
read more: dotNetTips.Utility 3.5 Released
What’s great about this is that you will get some serious tools and the VB.Net source to see how they work. Dave is a proponent of Standards and you can see in this library how he implements some of the techniques he talks about.
From AvailablePhysicalMemory to UsStateCollection the helpers get you from nowhere to somewhere fast.
Highly Recommended!
Codeplex Project: http://dotnettips.codeplex.com/
Wednesday, July 01, 2009
#
Antonio has put together a great list of VB Influencers to follow on Twitter
Antonio Chagoury - Tweeps List: Microsoft Visual Basic MVP’s
While his title says MVPs, there are some other influencers listed
Monday, June 29, 2009
#
Who is the “typical VB.NET developer”? Is there one? There are millions of VB.NET developers in the world, and they each have their own unique story.
Here’s mine:
· How long have you been using VB?
Since V1. In 1992, I was looking for a replacement to QBasic when developing a Point of Sale Application for Windows.
· What industry do you work in?
Software Development. We are very diversified in our client base, touching Medical Records, Financial Services, Home Automation, Factory Floor Control, Online Gaming, Media and Training.
· How big is your development team?
We are a small shop in terms of size. We leverage Code Generation heavily to compensate for not having code monkeys to type in all the repetitive code that goes along most applications.
· What kind of apps do you most commonly build?
Line of Business Web Applications.
· What’s the most interesting app you’ve ever built?
That's Top Secret. :-) I am doing my most interesting app development right now! Think Silverlight, Home Automation and Green Technology. Details will come out soon.
· Please tell us about an app that you’re working on at the moment.
Currently one of my applications is a system for helping Non-Profit Organization raise funds and advertise. We built the Proof of Concept in Silverlight 1.1 and are currently re-engineering for release in Silverlight 3.
· What other technologies do you most commonly use?
Code Generation, this is a pretty broad definition... I use many technologies depending on the needs of my client. Some of those include: Silverlight, WCF, ASP.Net, ASP.Net MVC, MEF and nHibernate.
· What are some of your favorite VB features?
XML Literals, Background compiler, Linq syntax in VB, Case Insensitivity.
· What do you like most about VB as a programming language?
I like VB because I can use it everywhere I work (asp, silverlight, office) and still retain a sense of familiarity with my syntax. VB code is much easier for me to read and review than other more cryptic languages. Also pretty much EVERYONE can read and understand my code... even the perl developers. I can't really say that about any other language.
For other interviews in this series, please visit http://imavb.net.
Tuesday, June 23, 2009
#
I do lots of work with collections and one thing I tend to frequently is log all the information I can about a certain Request under certain conditions.
I found myself needing to serialize or save all the Request.ServerVariables.
Now, we could walk through the items, blah, blah, blah, this ends up being much easier with an Extension Method:
Public Module NameValueCollectionExtension
<Runtime.CompilerServices.Extension()> _
Public Function ToXElement(ByVal self As NameValueCollection, ByVal RootElementName As String) As XElement
With self
If RootElementName = Nothing Then
RootElementName = .GetType().Name
End If
Dim xel As New XElement(RootElementName)
If .HasKeys Then
For i As Integer = 0 To .Count - 1
xel.Add(New XElement(.Keys(i), .Item(.Keys(i))))
Next
End If
Return xel
End With
End Function
<Runtime.CompilerServices.Extension()> _
Public Function ToXElement(ByVal self As NameValueCollection) As XElement
Return self.ToXElement(String.Empty)
End Function
End Module
To use this in your code, save the above as a Module.
Then in your ASPX Code Behind or elsewhere applicable (like Silverlight), simply use this:
Dim data = Request.ServerVariables.ToXElement()
Or This:
Dim data = Request.ServerVariables.ToXElement("ServerVariables")
I took the consideration of allowing you to set a ROOT Element if you don’t want to use the Variable’s Type Name by providing an Override that accepts a String for the Name.
Et, voila! You have a perfectly good XML Snapshot of all the Request’s Server Variables:
<HttpServerVarsCollection>
<ALL_HTTP>HTTP_CACHE_CONTROL:no-cache
HTTP_CONNECTION: Keep(-Alive)
HTTP_CONTENT_LENGTH:7654
HTTP_CONTENT_TYPE:application/x-www-form-urlencoded
HTTP_ACCEPT:image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
HTTP_ACCEPT_ENCODING: gzip, deflate
HTTP_ACCEPT_LANGUAGE: en(-us)
HTTP_COOKIE: ASP.NET_SessionId = *********************
HTTP_HOST:localhost:22318
HTTP_REFERER:http://localhost:22318/Public/MyPage.aspx
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; MS-RTC LM 8; .NET CLR 4.0.20506)
</ALL_HTTP>
<ALL_RAW>Cache-Control: no-cache
Connection: Keep(-Alive)
Content-Length: 7654
Content-Type: application/x-www-form-urlencoded
Accept: image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept(-Encoding) : gzip, deflate
Accept(-Language) : en(-us)
Cookie: ASP.NET_SessionId = *****************
Host: localhost:22318
Referer: http://localhost:22318/Public/MyPage.aspx
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; MS-RTC LM 8; .NET CLR 4.0.20506)
</ALL_RAW>
<APPL_MD_PATH/>
<APPL_PHYSICAL_PATH>C:\SourceCode\SomeProject\trunk\MyApp\</APPL_PHYSICAL_PATH>
<AUTH_TYPE/>
<AUTH_USER/>
<AUTH_PASSWORD/>
<LOGON_USER>DREAMSHOP\steele</LOGON_USER>
<REMOTE_USER/>
<CERT_COOKIE/>
<CERT_FLAGS/>
<CERT_ISSUER/>
<CERT_KEYSIZE/>
<CERT_SECRETKEYSIZE/>
<CERT_SERIALNUMBER/>
<CERT_SERVER_ISSUER/>
<CERT_SERVER_SUBJECT/>
<CERT_SUBJECT/>
<CONTENT_LENGTH>7654</CONTENT_LENGTH>
<CONTENT_TYPE>application/x-www-form-urlencoded</CONTENT_TYPE>
<GATEWAY_INTERFACE/>
<HTTPS/>
<HTTPS_KEYSIZE/>
<HTTPS_SECRETKEYSIZE/>
<HTTPS_SERVER_ISSUER/>
<HTTPS_SERVER_SUBJECT/>
<INSTANCE_ID/>
<INSTANCE_META_PATH/>
<LOCAL_ADDR>127.0.0.1</LOCAL_ADDR>
<PATH_INFO>/Public/MyPage.aspx</PATH_INFO>
<PATH_TRANSLATED>C:\SourceCode\SomeProject\trunk\MyApp\Public\MyPage.aspx</PATH_TRANSLATED>
<QUERY_STRING/>
<REMOTE_ADDR>127.0.0.1</REMOTE_ADDR>
<REMOTE_HOST>127.0.0.1</REMOTE_HOST>
<REMOTE_PORT/>
<REQUEST_METHOD>POST</REQUEST_METHOD>
<SCRIPT_NAME>/Public/MyPage.aspx</SCRIPT_NAME>
<SERVER_NAME>localhost</SERVER_NAME>
<SERVER_PORT>22318</SERVER_PORT>
<SERVER_PORT_SECURE>0</SERVER_PORT_SECURE>
<SERVER_PROTOCOL>HTTP/1.1</SERVER_PROTOCOL>
<SERVER_SOFTWARE/>
<URL>/Public/MyPage.aspx</URL>
<HTTP_CACHE_CONTROL>no-cache</HTTP_CACHE_CONTROL>
<HTTP_CONNECTION>Keep-Alive</HTTP_CONNECTION>
<HTTP_CONTENT_LENGTH>7654</HTTP_CONTENT_LENGTH>
<HTTP_CONTENT_TYPE>application/x-www-form-urlencoded</HTTP_CONTENT_TYPE>
<HTTP_ACCEPT>image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*</HTTP_ACCEPT>
<HTTP_ACCEPT_ENCODING>gzip, deflate</HTTP_ACCEPT_ENCODING>
<HTTP_ACCEPT_LANGUAGE>en-us</HTTP_ACCEPT_LANGUAGE>
<HTTP_COOKIE>ASP.NET_SessionId=**********</HTTP_COOKIE>
<HTTP_HOST>localhost:22318</HTTP_HOST>
<HTTP_REFERER>http://localhost:22318/Public/MyPage.aspx</HTTP_REFERER>
<HTTP_USER_AGENT>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; MS-RTC LM 8; .NET CLR 4.0.20506)</HTTP_USER_AGENT>
</HttpServerVarsCollection>
Remember, this is NOT limited to HttpServerVariables, it works with ANY NameValueCollection.
This can be a huge amount of data depending on what you are doing. You can always use Linq to get a subset of the Collection, or .Remove() some known XElements, like ALL_HTTP, ALL_RAW or All the empty nodes before persisting or displaying this.
Extension Methods offer a great solution to common problems when you don’t have access to write a Method for the Class. They are also great for making shortcuts to common scenarios for work you do with Collections or Conversions.
Click here for another useful extension for NameValueCollection by Tony Cavaliere from which I derived this idea, Thanks for sharing Tony!
Friday, June 19, 2009
#
Lisa Feigenbaum from the .NET Managed Languages Group about Visual Basic .NET. Does VB.NET have a future ? Does Microsoft love C# more than VB.NET? Listen and find out.
Of course it does… As Lisa says, it’s not in Microsoft’s best interest to stop moving VB.NET forward.
Yes, there is a bias about VB in general, but 99.9% of this comes from VB perception and not VB.NET. VB.NET is completely different and people do not realize it’s only related by SOME (not nearly all) syntax. The underlying IL is not really any different from C# when compiled. This is a marked difference in the way VB works internally.
Overall, I think this is a good refresher for people who (quite wrongly) think VB is going nowhere. VB is here for the long haul, bashers need to just get over it… You will see VB.Net development continue for the rest of most of our careers. That makes me a very happy developer.
Anyone still bashing VB is A) ignorant of what VB.Net really is and B) no different from being a racist, beating a drum that is stupid and irrelevant.
Misfit Geek Podcast
Monday, June 15, 2009
#
I was looking for a way to create some Repeating Strings easily and I got tired of typing.
You may notice that the String() constructor will allow you to create single repeating characters, but it does not let you create repeating Strings.
For example, creating this is simple:
Dim zeros As New String("0", 10)
which results in a String of ten zeros or “0000000000”.
This is a great way to make String with a single repeating character. So how to I repeat whole strings?
The first technique would be to use StringBuilder.Append, which is pretty efficient and apparently what most people use.
Then I saw this fairly old (2005) post from Eddie Garmon.
As a result, here is my VB version of String.Repeat()
Public Module StringExtensions
''' <summary>
''' Maximum performance for Initializing a repeating String
''' </summary>
''' <remarks></remarks>
<Runtime.CompilerServices.Extension()> _
Public Function Repeat(ByVal input As String, ByVal count As Integer) As String
If input Is Nothing Then
Return Nothing
ElseIf (input = String.Empty) OrElse (count < 1) Then
Return String.Empty
End If
Return String.Join(input, New String(count) {})
End Function
End Module
NOTE: in VB, don’t forget the {} Initializer or String uses the wrong Constructor and you get a compile error.
Now I have a really simple way to create repeated strings:
Dim repeated = "<col/>".Repeat(5)
or this:
Dim repeatThis = "<td></td>"
Dim repeated = repeatThis.Repeat(5)
which is easier to type than:
Dim repeated = String.Join(input, New String(5) {})
In addition, it’s going to handle the basic Error Trapping so I don’t have to repeat that every time too.
Monday, June 01, 2009
#
Right on the heels of the last major Phoenix event, we are happy to have Jaime Rodriquez and Karl Shifflett presenting a FREE 2 day course on the subject. If you can possibly get there, then you should.
Registration Link
Day One:
- Lap Around WPF
- WPF Tools ( Blend, Visual Studio 2008)
- Graphics Subsystem
- Layout
- WPF Fundamentals and new concepts
- Application Model
- Dependency Properties
- Trees (logical & visual)
- Events
- Threading
- Resources
- Controls
- Styling
- Templating
- Q&A with instructors at end of day
Day Two:
- WPF integration with Win32 and Windows Forms
- Data binding
- Introduction to Model-View-ViewModel
- Commanding in M-V-VM
- Views, Navigation and Transitions
- Data Validation
- Error handling, Model dialogs, Logging
- Unit Testing
- MVVM & LOB tips and tricks
- Q&A with the instructor
Knowing Karl, this is going to be a really DEEP DIVE, not a simple demo of stuff we would never use in production. I was very impressed by what Jaime presented last week and I was sorry to see him cut short.
I’ll be there helping out when I can on the Silverlight side of things and with M-V-VM the Architecture Pattern in General.
The real thing about programming in an architectural model like this is that it is a complete paradigm shift from the Winforms or Asp.Net style of programming. The Architecture is the most important thing to understand when you are creating Applications with these new Frameworks. Understanding the Architecture in full will help you to understand how what YOU do every day fits into that structure, making you a more valuable team member. If you are a Team of One, then it is even more important for you as a developer to really “get this.”
Every one of these concepts also applies to Silverlight, with the possible exception of Win32 Interop. If you think you would look more to Silverlight than WPF this tour is still going to help you in 90% of its content.
Here’s a quote from Jaime:
“Yes, joining our training and learning WPF will help you learn Silverlight. In fact, having trained both in the past, I think our training will help you much better understand Silverlight and prepare for the future. Things like Dependency Properties, RoutedEvents, are in Silverlight, but are not fully implemented yet. In our WPF training, we explain the whys and hows of all of these. Some of this goodness will continue to trickle into Silverlight over time and I have heard from people it helps to understand the design principle behind it.”
See you There!
Friday, April 24, 2009
#
AZGroups is pleased to present their 2009 Main Community Event featuring Scott Guthrie, Glenn Block and Jamie Rodriguez.
Here are the details and the link to register at the bottom of the post.
Sessions
ASP.NET MVC
Presented By Scott Guthrie (ScottGu)
We’ll walkthrough building an application from scratch using the recent ASP.NET MVC 1.0 release. You’ll learn what ASP.NET MVC is, the design decisions behind it, and how to build a real application with it. We’ll cover topics ranging from the basics of application creation through to concepts like unit testing and dependency injection.
Silverlight 3
Presented By Scott Guthrie (ScottGu)
We’ll walkthrough building applications using the new Silverlight 3 release. We’ll cover some of the power the new SL3 release provides, and then dive into how to program applications with it. We’ll cover how to build data applications with it, build eye popping graphic solutions, and enable out of the browser applications with it.
Building openly extensible applications in .NET 4.0
Presented By Glenn Block
Are you tired of building monolithic style apps? Are you tired of hacking your app to bits to meet just one more requirement. Do you want to enable third parties to provide add-on value to your apps? If the answer to any of these is yes, then come learn about the new Managed Extensibility Framework which ships in .NET 4.0. Applications built on MEF dynamically discover and compose available components at runtime. This makes MEF ideal for third-party extensibility scenarios, where the type and number of extensions are undefined. With MEF you can enable customers and third-parties to take your apps where no man has gone before.
The Microsoft Client Continuum: Sharing code, skills and tools between WPF and Silverlight
Presented By Jaime Rodriguez
Are you wondering why Microsoft has both WPF and Silverlight? Do they really need two technologies (given how similar they are)? This session will walk you through the different scenarios that both Silverlight and WPF are addressing today, we will cover the similarities, and differences between the platforms, and share pragmatic advise for building applications that exploit both platforms.
Speakers
Scott Guthrie is corporate vice president of Microsoft's .NET Developer Platform, where he runs the development teams responsible for delivering Microsoft Visual Studio developer tools and Microsoft .NET Framework technologies for building client and Web applications.
A founding member of the .NET project, Guthrie has played a key role in the design and development of Visual Studio and the .NET Framework since 1999. Guthrie is also responsible for Microsoft's Web server platform and development tools teams. He has also more recently driven the development of Silverlight – a cross browser, cross platform plug-in for delivering next generation media experiences and rich internet applications for the Web.
Today, Guthrie directly manages the development teams that build the Common Language Runtime (CLR), ASP.NET, Silverlight, Windows Presentation Foundation (WPF), IIS, Commerce Server and the Visual Studio Tools for Web, Client and Silverlight development.
Guthrie graduated with a degree in computer science from Duke University.
Jaime Rodriguez is a Senior Technical Evangelist in Microsoft's Client Evangelism team. Jaime's current mission is to show customers how easy it is to accomplish both great software architecture and amazing user experiences using Windows Presentation Foundation and Silverlight. You can follow Jaime's musings at http://blogs.msdn.com/jaimer.
Glenn Block is an industry expert with broad enterprise software development experience including architecture and system design. Strong proficiency in designing software frameworks and infrastructure. Driver of technical strategy for small and large organizations. Professional speaker who has presented at both industry and community events.
Glenn Block’s Specialties:
Agile practices, Architecture, Design patterns, Driving Technical Strategy, Program Management, Product Planning
Registration: AZGroups.org 2009 Scott Guthrie Event
Thursday, April 23, 2009
#
Serge came up with a cool use of the Twitter API for his blog…
Twitter Ticker - VB
25 latest tweets about Visual Basic
sergeb.com: Twitter Ticker - Visual Basic
Nice idea to get live aggregated info from social networks that apply directly to your content
Found this link today… awesome stuff here, expect a VB sample here soon.
Declarative language constructs like query comprehension syntax often worries imperatively trained developers. I hear this quite a bit, and the excuse of “It Just Works” is often not satisfactory for most of them :-). Combine this with interesting behavioral differences like lazy evaluation and lots of developers get lost in paradise.
Actually the perceived problem is not with LINQ itself, typically a lack of solid understanding about the query execution model causes grief. So one thing that can help to address this problem is a better visualization of how a query executes. Advanced query “providers” like LINQ to SQL offer logging capabilities to inspect what’s going on, but LINQ to Objects lacks such a capability.
In this post, we’ll have a look at possible approaches to make debugging LINQ to Objects (and hence LINQ to XML) queries easier. At the end of the day you’ll come to the conclusion it all boils down to knowing precisely what the semantics of the various operators are and how the execution works in the face of laziness etc.
LINQ to Objects - Debugging - B# .NET Blog
Thursday, April 09, 2009
#
I found this today from Paul Welter… Easier way to page Linq queries.
Here is the Proper VB Equivalent Snippet:
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Public Module PageQuery
''' <summary>
''' Easily get Pages for an IQueryable(Of T)
''' </summary>
''' <typeparam name="T">any IQueryable supported Type</typeparam>
''' <param name="query">The Query we are Paginating</param>
''' <param name="page">Page Number (starts at 1)</param>
''' <param name="pageSize">Number of Items per Page</param>
''' <returns>Reduced query with a single page of information</returns>
''' <remarks></remarks>
<Runtime.CompilerServices.Extension()> _
Public Function Paginate(Of T)(ByVal query As IQueryable(Of T), _
Optional ByVal page As Integer = 1, _
Optional ByVal pageSize As Integer = 10) As IQueryable(Of T)
If query Is Nothing Then Return query
Dim skip = Math.Max(pageSize * (page - 1), 0)
Return query.Skip(skip).Take(pageSize)
End Function
End Module
I found this to be more intuitive for doing this:
Dim query = From row In db.Invoices _
Order By row.InvoiceID Descending _
Select row
Return query.Paginate(page, pageSize).ToList()
Instead of this:
Return query.Skip(skipRows).Take(takeRows).ToList()
Notes: VB doesn’t like the Namespace in the C# Sample code and it’s not needed for us. Also remember you should always use an Order By when Paging.
I also added a trap so that if the Query is Nothing it doesn’t throw a NullReferenceException.
Tuesday, April 07, 2009
#
Eric has released PLINQO version 3.0 in BOTH C# and VB for CodeSmith
Changes are an inevitable part of any project. The LINQ to SQL designer in Visual Studio provides a lot of support for manipulating entities, but does NOT make it easy when a refactor is required. The LINQ to SQL designer requires that the entity be dropped and recreated to generate the necessary updates. When the entity is dropped, any updates made for that entity are also lost and now must be re-created. This is time consuming, tedious and results in work being done over and over again. With PLINQO, make changes, right-click, generate, DONE!
PLINQO Rules! Yes, PLINQO provides several different ways to lay down the law. Rules can be added programmatically or declaratively through attributes. Constraints like property length and required field rules can be enforced. Regular Expression data validation as well as several built in rules including authorization rules are possible with PLINQO. Before any data is saved, the rules are automatically executed against any entities in your change set. If any rules are broken, a BrokenRulesException will be thrown with a list of the rules that were broken and the entity will not be updated.
The PLINQO rule manager generates rules based on the schema and any custom rules can be added to the rules collection. The rules are enforced when any attempt to save changes is made. Custom rules are a snap to add and the AddSharedRules partial method on each entity is the place to add them. Only a few lines of code and a custom rule can be added.
PLINQO - Supercharged LINQ to SQL
Very good stuff here.
Monday, March 30, 2009
#
My most recent article is up at Visual Studio Magazine Online.
I choose to pick the tools that apply directly to a problem I need to solve and use those new capabilities to enhance my productivity. Even more power and flexibility comes when we can take several of these capabilities and combine them for a unique solution to a problem.
We're going to look specifically at three pieces of the framework that can be combined to provide a new technique. This technique helps in writing more responsive ASP.NET pages, while at the same time making the code more readable. The three technologies are: XML literals, Windows Communication Foundation (WCF) Factory Services and LINQ. XML literals and LINQ are new in Visual Basic 9 (VB9). LINQ gives us a common syntax for querying just about any data, be it SQL, XML or objects. Even though WCF has been here for a while, the out-of-the-box readiness for building factory services is little-known. Here we'll show you how to create WCF services without changes to config files for endpoints, behaviors and bindings.
Visual Studio Magazine Online | On VB: XML Literals, WCF and LINQ
I look forward to presenting more of these in the future. I will also be talking about this these techniques for a while, hopefully at the next Desert Code Camp.
Code samples for this article: Templating with XML Literals
Wednesday, March 25, 2009
#
We lobbied hard for this, now we have it… GO USE IT! :-)
What's New?
Silverlight Toolkit - Release: March 2009
The Composite Application Guidance for WPF and Silverlight is designed to help you more easily build enterprise-level Windows Presentation Foundation (WPF) and Silverlight client applications. It will help you design and build enterprise-level composite WPF client applications—composite applications use loosely coupled, independently evolvable pieces that work together in the overall application.
This is a great set of guidelines for building WPF, Silverlight Applications and shows you how to build a common framework between the two.
Saturday, November 29, 2008
#
From all the great tools we have out there such as LLBLGen Pro, nHibernate and OpenAccess, why do I stick with a half baked moving target from Microsoft? Simply because it is in the box? Not really, it is because this is what most clients will be ASKING me to use.
There are a lot of things to like about Linq to Sql, and yet there are a lot to dislike as well.
My #1 Problem with L2S is the way the DataContext works, it is in no way designed for use in a mostly stateless or disconnected scenario. With a little effort you can work around this with some generous use of attach and being careful how you load and save objects.
My #1 Problem with L2E is the way the object model works. I hate not having access to defined columns in my DB when I really do want them and there is no valid option in the designer to support them.
As an example for this, I have a Login table that deals with all my User Security. Every table has a CreatedBy and UpdatedBy column... They all have a foreign key mapping back to Login to make sure no one enters an invalid login in these fields...
This is a pretty common scenario and generally is no big deal. Except with the model proposed by L2E I will have hundreds of associations back to the Login Table (none of which get named properly even when all the FK_xxx names are set. I have to manually wade through all the tables and change the names on BOTH sides to something that makes sense.
This is AWEFUL! I would never, never use an association such as "give me all addresses updated by John". To make these matters worse, I can't even get the Address's CreatedById unless I load the entire Login object and reference it like this: Address.CreatedByLogin.LoginId which sucks when you are programming and creating queries.
Are there ways around this? sure, but they are all so complex and tedious that using L2E is simply too complex for 80% of my work. In the 20% case where I really do need the extra features complex mapping, I would be using some other tool such as LLBLGen Pro or OpenAccess because it is far easier to work with.
80% of our work is dealing with read-mostly scenarios and rich web presentations of the data.
What handles this best? Linq to Sql, why? Because it is easy to use and with Damien Guard's T4 Templates I can pound out a new DBML really fast.
Will Linq to Sql really die? Eventually, but not in the next couple years. here is a quote from Damien about it:
Where next
The decision has been made that Entity Framework is the recommended solution for LINQ to relational scenarios but we are committed to looking after our users and are approaching this in two ways.
Firstly we are going to make sure LINQ to SQL continues to operate as it should. This doesn’t just mean making sure what we had works in .NET 4.0 but also fixing a number of issues that have arisen as people pick it up for more advanced projects and put it into production environments.
Secondly we will evolve LINQ to Entities to encompass the features and ease of use that people have come to expect from LINQ to SQL. In .NET 4.0 this already includes additional LINQ operators and better persistence-ignorance.
This isn’t to say LINQ to SQL won’t ever get new features. The communities around LINQ to SQL are a continuous source of ideas and we need to consider how they fit the minimalistic lightweight approach LINQ to SQL is already valued for. Where these suggestions fit with this strategy we will be working hard to get them into the product. Some enhancements like the T4 templates can be released independently but runtime elements need to stick to the .NET Framework schedule.
In conclusion
DON’T PANIC
(in large, friendly letters)
LINQ to SQL will continue to work and EF will better address the needs of LINQ to SQL users with each new release.
In fact, I have a self-servicing class that all my L2S Entities inherit from and makes this scenario extremely simple and friendly for a developer to create fast, easily accessible data with plenty of robust data integrity.
By the time L2S is truly finished, there will be another solution, or the EF team will finally figure out how to adopt the L2S scenarios that make it so attractive. So for today, I am sticking with Linq to Sql instead of abandoning it in fear that EF will be the only solution.
Wednesday, November 05, 2008
#
In the past, I have usually blogged about PDC as it happens. This year there were so many things going on that I decided to wait until I returned to enter all the pertinent details for the VB Developer that were announced or shown at PDC.
Where do I start? There are several entries that I will be writing over the next couple weeks to cover these. In addition, some things I am working on are destined for publishing to another outlet, more on that when it happens.
One think I want to get out up front. The VB Language Team has a new leader, We will all miss Paul Vick and his invaluable contributions to the language as its leader for the past 10 years who will now move to "Language Designer Emeritus". Fear not VB Enthusiasts, his successor, Lucian Wischik will provide the forward thinking we need to keep VB.Net a great language and a terrific development platform.
I had the pleasure to talk with both while at PDC and my take away from conversations with Lucian, is that VB is in good hands and I expect to see great things come from his tenure as Language Specification Lead.
One of my first entries to come this week will be about something I have been working on that is only available using VB and XML Literals. I hope to provide some more insight into using VB in a practical sense to solve real-world problems in the coming months so stay tuned as these get posted.
VB10 is going to get some really important updates in the next release to further improve your productivity. Among these are array literals, collection initializers, automatic properties, implicit line continuations, statement lambdas, generic variance, and a feature that embeds primary interop assembly types in your assembly so you don’t have to deploy the PIA. There is also something coming for the Framework in general that make Parallel Processing really easy.
I will be writing samples on how to implement these in your general development over the next few weeks as we get the availability of a CTP that we can use.
Rest assured, VB.Net is not going away anytime soon and will remain my language of choice for all development. Rumors of the Death of VB are nothing more than false rumors or in some cases wishful thinking by language bigots.
Sunday, September 28, 2008
#
from: Scott Hanselman's Computer Zen - jQuery to ship with ASP.NET MVC and Visual Studio
Microsoft is going to make jQuery part of the official dev platform. JQuery will come with Visual Studio in the long term, and in the short term it'll ship with ASP.NET MVC. We'll also ship a version includes Intellisense in Visual Studio.
The Announcement Blog Posts
This is cool because we're using jQuery just as it is. It's Open Source, and we'll use it and ship it via its MIT license, unchanged. If there's changes we want, we'll submit a patch just like anyone else. JQuery will also have full support from PSS like any other Microsoft product, starting later this year. Folks have said Microsoft would never include Open Source in the platform, I'm hoping this move is representative of a bright future.
This is really good news for jQuery users. It means that it will just be there all the time and there will be a stable, supported reference to use when debating the reasons to use it to management.
jQuery makes developing with Javascript much easier and does wonders for manipulating CSS at runtime.
Thursday, September 25, 2008
#
Silverlight 2 Release Candidate 0 (Silverlight 2 RC0) is now available to developers for testing purposes
The Official Microsoft Silverlight Site
Time to get ready for the next release. There are some interesting breaking changes, the most important being a change to the Object reference from the web page hosting your Silverlight App.
I will sure write up some gotchas if I run across anything strange.
Tuesday, September 23, 2008
#
Damien Guard has made his T4 Templates Output to VB (yeah!).
LINQ to SQL T4 template for Visual Studio 2008
The latest update to my template for generating LINQ to SQL classes from DBML is now available.
If you want to customize the LINQ to SQL code generation phase in your project without additional tool dependencies this could be what you’re looking for.
I was looking for a better way to customize the Linq to SQL CodeSpit and this lets us do it from inside Visual Studio in a very painless way. No extra tools required. CodeSmith and CodeRush are still quite valueable, but this method integrates very nicely without requiring extra tools.
Thanks to Jim Wooley for pointing me to it, I was not aware how far this had come.
What's T4? In short, It's Native Code Generation inside Visual Studio 2008 (and 2005 with extensions)
Oleg Sych explains most of it here.
When I first saw this, I did not think it was what I needed, it turns out it was EXACTLY what I needed, I just didn't know it. This is well worth your time to investigate if you are doing any code generation for LINQ. (or anything else for that matter, T4 doesn't care, you can codegen a UI using XAML or HTML with it quite easily).
Blogroll Me!
Copyright © 2003-2009 H. Steele Price, IV -
All opinions are my own, not necessarily those of my employer, your mother, or any government agency.