My Gestalt

Understand the chaotic world by developing meaningful perception through the acquisition of seemingly disparate knowledge.

Collect information in large quantity with precise detail and connect the dots of meaning to form your own picture of the universe.

Act upon it

Knowledge and understanding without action is waste.

Be Grateful

Never underestimate the power of gratitude.

Charity

Forgiveness will make your heart happy. Forgiveness is not about someone deserving it, it's about healing your heart.

Thursday
Apr232009

LINQ to Objects - Debugging

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
Apr092009

More intuitive way to page Linq queries.

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
Apr072009

PLINQO - Supercharged LINQ to SQL Now Available

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
Mar302009

XML Literals, WCF and LINQ

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
Mar252009

VB Samples for Silverlight Toolkit Available in March 2009 Release

We lobbied hard for this, now we have it… GO USE IT! :-)

What's New?

Silverlight Toolkit - Release: March 2009

Wednesday
Mar252009

Visual Basic QuickStarts and How-to Topics for the Composite Application Guidance for WPF and Silverlight - February 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
Nov292008

Why I choose to ignore reports of the death of Linq to Sql...

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
Nov052008

PDC Overload

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
Sep282008

jQuery to ship with ASP.NET MVC and Visual Studio

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
Sep252008

Silverlight 2 RC0 is now available to developers

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.

Page 1 ... 2 3 4 5 6 ... 40 Next 10 Entries »