|
|
Articles
Short articles written and published by Jason Follas
It seems that I'm always struggling to simplify my code. As such, I was playing with Knockout today, and found that in multiple places, I needed a string containing concatenated values of multiple observables
Take this simple example of binding a dropdown to a view model, and also showing the selected value in a span. The items being bound are not simple strings, but rather, are complex objects containing multiple attributes. The string that I ultimately want to display is a concatenation of the first and last names of the employee, but without doing anything special, the rendered text will be:...
Background
From the Wikipedia article, Leadership in Energy and Environmental Design (LEED) is described as “an internationally recognized green building certification system, providing third-party verification that a building or community was designed and built using strategies intended to improve performance in metrics such as energy savings, water efficiency, CO2 emissions reduction, improved indoor environmental quality, and stewardship of resources and sensitivity to their impacts.”
In my own words, LEED is a certification system that awards points for following certain environmentally-friendly practices when constructing a building. In the end, a building can be qualify for one of four different levels of certifications, based...
DbGeography Static Property
Return Type
DbGeometry Static Property
Return Type
DbGeography.DefaultSrid
...
Today, I began to look into the Entity Framework June 2011 CTP which includes first class support for Spatial data types. The ADO.NET team created an abstraction layer, based on the OGC simple features specification, with a goal being to support spatial implementations from multiple vendors. As you would expect, SQL Server 2008 Spatial is supported out of the box.
For some reason, I was expecting a lot of work to be done on the client-side within their abstraction data type. I was pleasantly surprised to see EF pass the heavy lifting to the underlying data store as part of the...
I recently had to work with some code that I wrote a few years ago, and stumbled upon this:
(Not that it's relevant to the rest of this blog post, but this code was responsible for deleting a Role in a custom membership provider, but due to foreign key relationships without cascading deletes, all of the User/Role assignments had to be deleted first)
Now, in all fairness to myself, there's really nothing wrong with this code. Array.ForEach<T> requires an Action<T> delegate, and this anonymous method certainly qualifies as one.
However, since the time that I wrote this particular piece of code, I started...
Have you ever become distracted while scrolling through code, or switched to another tab and then forgot what you were working on? It happens all the time when we try to multitask while coding. If only there was a call stack for our brains that we could just unwind to find our way back to where we started....
Turns out, there is!
CodeRush includes a feature called "Markers". These are little placeholders, or breadcrumbs, for your cursor location that can be created just before your focus changes to another part of code. When you're done with whatever task distracted you, simply hit...
CodeRush is full of templates. Thousands of them, when you combine the basic templates with the various types that are supported by each. How does someone start to learn all of the required mnemonics in order to use CodeRush effectively?
The answer to that is a brilliant feature known as the CodeRush Tool Window:
(DevExpress menu in Visual Studio, Tool Windows -> CodeRush)
The CodeRush Tool Window provides a context-sensitive list of "next characters" in CodeRush templates that are valid at the cursor's current location. As you start to work with CodeRush, leave this window open (perhaps on a second monitor) so that...
There is A LOT of repetition in coding. To accomplish certain things, you often need to include boilerplate code that is repeated throughout your program.
Take Properties, for instance. Defining Properties on a class, especially a lot of them, can be a very tedious task.
Traditionally, you have to create a member variable of the class to serve as the Property's backing store, and then create the Property itself (with a getter and setter to interact with that member variable). Lather, rinse, repeat... ad nauseum.
This type of work is where CodeRush excels by providing you with mnemonic-driven code templates. In...
Do a search, and you will find that there are a few IDE Productivity Tools available for Visual Studio. As far as feature sets go, you'll also find that there is quite a bit of overlap in what these tools offer. So, deciding on one is largely a matter of personal preference.
However, by not using an IDE Productivity Tool at all, you are doing yourself a great disservice. No, really! You are wasting a lot of time by manually doing things instead of allowing software do it for you. Since time is money, and these tools are not very...
I’ve spent the last few week, or so, reading through Azure in Action by Chris Hay and Brian H. Prince. This book is not yet published, so my copy was in the form of a PDF provided by the Manning Early Access Program (http://manning.com/about/meap).
The book is broken into parts, with 2-4 chapters per part:
Welcome to the cloud
Understanding the Azure service model
Running your site with web roles
Working with blob storage
Working with structured data
Doing work with messages
Each...
In this, the third part of a series of articles examining Windows Azure platform AppFabric Access Control (Part 1, Part2), I will continue developing the [somewhat contrived] nightclub web service scenario and demonstrate how to obtain a token from ACS that can be used to call into a Bartender web service. A Quick Review Our distributed nightclub system has four major components: A Customer application coupled with some external identity management system, a Bartender web service, and ACS, which acts as our nightclub’s Bouncer. A Customer application ultimately represents a user that wishes...
In the previous article, I provided an example scenario of how claims-based access control might map to the real-world event of a customer entering a bar. This article will build upon that concept, eventually enabling a Customer application to obtain a token from our Bouncer (ACS), and then use that token to order a drink from the Bartender web service.
Now let’s walk through how to create a Service Namespace in Windows Azure, which is needed to permit your application and/or web service to utilize AppFabric Access Control.
Service Namespace
At this time, Windows Azure platform AppFabric provides two services for developers to...
The Windows Azure platform AppFabric Access Control service was one aspect of the Windows Azure platform that I found a bit challenging to understand, primarily because identity is not a domain that I regularly work with. This post, the first in a planned series of articles, will explore what the Access Control service is and why it is useful.
Three Geeks Walk Into a Bar…
Let’s examine a common real-world scenario: Ordering a drink from a bartender at a nightclub.
Before the nightclub opens, the bouncers inform the bartenders about the token that customers will bear on that night to indicate...
I was working through some Windows Azure example code today, and came across a situation where IntelliSense did not show a method that the sample code used (CreateCloudBlobClient(), in this case):
var storageAccount = Microsoft.WindowsAzure.CloudStorageAccount.FromConfigurationSetting("DataConnectionString");var blobStorage = storageAccount.CreateCloudBlobClient();
A lot of times, when I'm exploring an API, I will type out the fully qualified class name in code so that I can use IntelliSense to see what the other members exist in the same namespace. And, while I'm exploring, I usually don't bother to include a using statement at the top of my code because it's so easy to just use the...
July 28, 2011 Note: This is an outdated post. Recently, the ADO.NET team has released a CTP with Spatial support as a first class citizen of the Entity Framework!!! See the following posts that I wrote as I explored the new API:
http://www.jasonfollas.com/blog/archive/2011/07/20/entity-framework-spatial-first-look.aspx
http://www.jasonfollas.com/blog/archive/2011/07/21/entity-framework-spatial-dbgeography-members.aspx
http://www.jasonfollas.com/blog/archive/2011/07/27/entity-framework-spatial-a-real-world-example.aspx
The Entity Framework does not support using User Defined Types (at least in the SQLCLR sense of the term) as properties of an entity. Yesterday, Julie Lerman contacted me to see if we could find a workaround to this current limitation, particularly for the SQL Server Spatial Types (Geometry and Geography).
Whenever I hear of someone wanting to use Spatial...
Over the weekend, I bought a Motorola Droid, a great new Android 2.0 phone on the Verizon network. It's important to note that this is not only my first smart phone, but also my first hand-held device of this type (i.e., a PDA, etc), so I'm pretty stoked at the moment.
The device synchronizes with Google applications extremely well (like GMail, Google Calendars, Google Voice, Contacts, etc). Setting this up is just a matter of creating a new Account on the phone, providing your GMail account and password, and then everything else just magically syncs. And, since I'm primarily a GMail user...
I'm a consultant. I travel from client network to client network, sometimes within the same day. My job involves interacting with various corporate servers using my trusty laptop, solve real-life business problems, and then move on to the next gig. It's not practical for me to have my computer join a Windows Domain only to have to do it again and again with each new environment that I visit. This is also not feasible because I cannot have my different clients become administrators on my company-provided laptop or have domain policies pushed down to my laptop, which is a byproduct of joining a domain.
So, as...
SQL Server Reporting Services is great in the fact that it comes with a handful of different rendering (export) formats out of the box. If a particular report is intended to be paginated and printed, then from my web applications, I will often link to the report with a parameter instructing the render format to be PDF - this way, the user is never taken to the report viewer (they just get an Open/Save As dialog for the PDF itself).
The URL for such a link may resemble the following:
http://server/ReportServer?/path/reportname&rs:Command=Render&rc:LinkTarget=_blank&rs:Format=PDF&SomeParameterValue=1
There are other interesting things that you can do with the rs:Format...
Microsoft Regional Director (and friend) Steven Smith has a great talk about ASP.NET performance tips - I've seen the presentation probably a handful of times already, and always seem to walk away with something new to try that I didn't quite "grok" previously.
But, here's one additional tip that I can offer that is easily overlooked, yet very important for enterprise development.
Enterprise web applications (at least in my world) tend to use Integrated Security in order to provide Single Sign-On capability (i.e., automatically authenticating the user according to their Active Directory credentials). As such, Anonymous access to the web application is usually...
I've previously mentioned that the SQL Server 2008 Spatial data types are freely available for use in your .NET applications, regardless of whether you have SQL Server 2008 or not. This allows you to incorporate some powerful spatial capabilities right into your application.
(Look for "Microsoft SQL Server System CLR Types" on this page: http://www.microsoft.com/downloads/details.aspx?FamilyID=228DE03F-3B5A-428A-923F-58A033D316E1&displaylang=en )
However, in most usage scenarios, there will come a time when you have an instance of a SQL Server spatial object in your .NET application, and need to commit it to your SQL Server 2008 database. How would you do this, without losing fidelity or...
I have mentioned before how the Ring Orientation for the exterior ring of a Polygon is significant when instantiating a SqlGeography object. In this case, a Counter-Clockwise orientation is required so that as an observer walks along the path, the interior of the Polygon is always to their left.
But, what I have never really seen documented (or paid attention to, at least) is the fact that the interior rings, or holes, of a Polygon also have specific Ring Orientation requirements.
In keeping with the "Left-handed" rule, interior rings must be defined in a Clockwise manner - the opposite orientation of the...
A Ring is a list of points such that the starting point and ending point are the same (forming a closed shape). The order the you define the points that make up a Ring - known as Ring Orientation - is significant, for various data formats (including SQL Server's Geography type) imply special meaning for rings that are defined in a clockwise manner as opposed to a counter-clockwise manner.
Given a list of points with no additional context, it can be difficult to determine the Ring Orientation being used.
For example, suppose that you have a generic list of points that...
I use Windows 2008 Server as a workstation. I find that certain things actually work better (like Sleep Mode, for instance, which is weird because servers shouldn't need to sleep, but Vista would often not go to sleep and drain my battery the entire couple of hours that it continued to run in my computer bag, and Windows Server 2008 has never done that.... but I digress).
However, when the new Zune 3.0 software was released today, I found, like many others, that the software explicitly listed three operating systems that were supported, and Server 2008 was unfortunately not one of...
Have you ever gotten an idea stuck in your head? One that you start your day thinking about in the shower, and then try as you might, you just can't get rid of it?
That's what happened to me a few months ago. Specifically, I started thinking about Twitter, and the problems that it was experiencing. At that time, the "Fail Whale" was making very frequent appearances, indicating that Twitter was having problems keeping up with the demands being made on it. My Tweeps (social networking friends on Twitter), all with short attention spans like myself, began chattering about moving to...
In this, the eighth part in a series on the new Spatial Data types in SQL Server 2008, I'll step away from the database and do a little spatial coding using .NET.
Redistributable .NET Library
Up to this point in the series, I have demonstrated a lot of interesting (?) things that you can do with the new Spatial data types (Geometry and Geography) in SQL Server 2008. You might be thinking, "That's swell, and all, but I wish I could do some of that stuff without needing to be tethered to a database." Well, you know what? You can!
I mentioned in...
Tuesday at the NWNUG meeting, Steven Smith spoke on various ways to squeeze performance out of your ASP.NET applications. This was a fantastic talk, and gave me plenty to think about (since ASP.NET is not my forte, I only consider myself to have an intermediate skillset on this topic).
One suggestion that he made involved caching database writes. That is, instead of immediately writing logging-type information to the database for every request, which is a relatively expensive operation considering the small payload size, that you could accumulate them in a short-term cache, and then perform the write operation periodically. Fewer database...
This morning's goal was to quickly install SQL Server 2008 RC0, and then move on with some project work. Let's just say that my project work should resume by this afternoon...
In the interest of disk space, I removed an existing installation of SQL Server 2005 Developer Edition. And then the installation of 2008 RC0 began by installing the "Microsoft.NET Framework 3.5 SP1 (Beta)"... which is probably "install-smell" for me needing to pave my machine when the product finally RTM's. But, I digress...
The installation went pretty smoothly until it came time for the "System Configuration Check" that takes place after you...
This meme is brought to you by Michael Eaton, who just so happens to be a huge fan of my spatial talks. ;-)
How old were you when you started programming?
Well, we might need to better define "programming" here.
I started tinkering with computers when I was about 6 or 7 (is that right, Dad?). In those days, it was more about reading a book about BASIC and typing in the program to run. Then I would make changes to the program to see the results. If modifying an existing program is considered "programming", then this is my epoch.
I really didn't start creating...
The Open Geospatial Consortium's Simple Features specification, which SQL Server 2008's Geometry data type is based upon, defines standards for working with spatial data using a flat-earth (projected planar) model. Ironically, these standards don't exactly cover the intricacies of using an ellipsoidal model, which is needed to "accurately" represent the world that we live in. In other words, the OGC standards define how to work with paper maps of the world, but not globes.
Fortunately, the SQL Server team recognized that that the Geometry type is inadequate for a lot of scenarios, and implemented a second data type just for representing...
It seems that a lot of my friends are doing Project Euler (according to my High School math teacher, this is pronounced "Oiler"). For example, Bill Wagner has been posting C# solutions, Darrell Hawley has ventured into the Python realm, and Dustin Campbell has been working on F# versions.
I love numbers, and spent a good portion of one summer playing with primes and number fields just for fun (since then, I've discovered WoW, and that takes up all of my time that would otherwise be spent exercising my brain). Project Euler is actually right up my alley, and while in...
In the Part 4 and Part 5 of the series, I demonstrated some instance methods of the Geometry type that returned a new Geometry based on existing instances. In this part, I will concentrate on instance methods and properties of the Geometry type that return scalar values and Points.
STArea, STLength
Typically, your spatial data will represent something from the real world. A LineString may be the collection of points gathered from a GPS device, and together they may represent the path that you took from your home to the office. A Polygon may be the collection of points around the...
A friend of mine (name withheld, I didn't actually ask if I could blog this... ;-) asked for advice to what appears to be a simple problem until you try to implement it. Consider the following somewhat normalized table:
AccountNum
...
In the previous part of this series, I demonstrated instance methods that transformed a single Geometry type into another useful Geometry. In this post, we'll go a step further and show methods that allow two or more instances to interact with one another in order to produce a new Geometry.
For my baseline, I'll use two Polygons that overlap each other:
DECLARE @g geometry
= 'POLYGON((10 10, 40 10, 40 40, 10 40, 10 10))'
DECLARE @h geometry
= 'POLYGON((30 30, 50 30, 50 50, 30 50,...
In this, the 4th post in a series (Part 1, Part 2, Part 3) on the new spatial data types in SQL Server 2008, I'll explain some of the methods that are used to transform a single Geometry instance into another useful Geometry instance. Note that I'm using Geometry for simplicity, but these techniques also work with Geography. Edit: Ok, after starting to take a hard look at Geography, I realized that A LOT of the methods that Geometry offers are not implemented in Geography. :-/ Sorry to mislead you.
Useful TipTo help me to visualize geometries as I explore the...
In the previous parts of this series (Part 1, Part 2), I introduced the Geometry and Geography data types, the various subclasses (Point, LineString, Polygon, etc), and demonstrated a little bit of the Well-Known Text (WKT) syntax. These two posts were primarily informational in nature, and didn't touch SQL Server at all. Let's change that!
Instantiating the UDT
The Geometry and Geography data types are implemented as User Defined Types (UDT) written in .NET. They are automatically installed with the server, and are available for use by any SQL Server 2008 database. For this post, I will use the Geometry type to...
In the first part of this series, I provided a somewhat verbose description of the two different types of Spatial data supported by SQL Server 2008: Geometry (flat Earth model) and Geography (ellipsoidal model). Now, let's dive in a bit deeper, and take a look at some of the specifics.
Standards
From their website, the Open Geospatial Consortium, Inc. (OGC) is described as "a non-profit, international, voluntary consensus standards organization that is leading the development of standards for geospatial and location based services." Unlike me, these folks are the real experts in the field who understand both the problems and the solutions...
Around the 1995 timeframe, two very different systems opened my eyes to the power of geospatial data, particularly how it can be used to enable an analyst to make better business decisions. At the time, I was working in IT at the hub sorting facility for an overnight freight company that specialized in heavyweight cargo. This company not only had a fleet of aircraft flying freight around the country, but also operated a large fleet of trucks (both linehaul and LTL).
Shortly after leaving that company, I was tasked with working on an e-commerce system that had some unique sales territory...
Beyond Relational
The introduction of SQLCLR in SQL Server 2005 allowed for very rich User Defined Types to be utilized. This meant that a developer could create a single object that contained multiple data points (properties) and could also perform calculations internally (methods), yet store that instance in a single field of a single row in a database table. Suddenly, any type of data could be stored and queried in the database, instead of just strings and numbers.
Fast forward to the present time, as Microsoft is celebrating the launch of SQL Server 2008 (notice that in the brilliance that is known...
The problem: A user tries to open a report from SQL Server Reporting Services using Internet Explorer. They are prompted for their username and password, despite the fact that their machine is part of an Active Directory domain. The expectation is that since the SSRS server is on the local intranet, that the logon would happen automatically. The findings: The server was incorrectly being assigned to the [external] Internet zone by Internet Explorer. By default, IE will not automatically log you into a website located in this zone as it would if the website was...
I received a support email yesterday for a system that I had written a few years ago. It seems that they were running year-end reporting, and total combined profit numbers were coming out in the quadrillions. It would have been a nice profit to report, but alas, not an accurate one.
When a number is magnitudes larger than what it should be, and there is division involved in a calculation somewhere, then that smells of floating point math issues. In this case, there was a SUM() being performed on a series of numbers, and instead of the result being a true zero,...
The Problem
The new Zune firmware is out! Yay!
The Zune software still uses BITS as the only means to download the firmware. Boo!
BITS doesn't like being behind a HTTP proxy server that requires authentication. In my particular situation, I must authenticate against a Microsoft ISA Server using Integrated Security (i.e., NTLM authentication) before my machine is permitted to receive files from a remote webserver.
But, by default, BITS doesn't automatically provide your domain user information to the proxy server. So, when the Zune software attempted to use BITS to download the firmware, it failed, and I only got a "C00D11CD" error...
SQL Server Integration Services (SSIS) is a huge step forward from its predecessor, Data Transformation Services (DTS). One thing that they have in common, though, is that there is no one simple method to allow a database user to execute a SSIS package on demand.
SSIS is THE centerpiece of Microsoft's ETL (Extract-Transform-Load) offering. In lay terms, SSIS is the tool that you use to import data into your SQL Server database from any number of sources, and it's a fantastic tool for doing so... so long as your environment doesn't change often... and you execute the package from Visual Studio or the...
This article was prompted by a question from the audience about the internals of XML Indexes. In particular, they were interested in where the internal system table used by Primary XML Indexes is stored, and what might happen to this index if the database is detached and then reattached on another server.
http://www.jasonfollas.com/wiki/SQLXML_Tricks_XMLIndex.ashx
Note: I will likely continue to expand on this particular article to include information about secondary indexes and when to use each type.
An audience member asked me if there was a way to be able to determine the element names that exist within the XML stored in a table. His business problem was that he archives XML in a field of a table, and needed to identify whether one row's XML contained a different set of elements than another row's (i.e., if an untyped XML's "schema" changed between versions).
In this article, I demonstrate T-SQL and XQuery syntax that will generate a table structure containing a list of element names (per primary key value). From this point, "traditional" querying can be used...
|