<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tallan&#039;s Technology Blog</title>
	<atom:link href="http://blog.tallan.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tallan.com</link>
	<description>Tallan&#039;s Top Technologists Share Their Thoughts on Today&#039;s Technology Challenges</description>
	<lastBuildDate>Tue, 17 Apr 2012 20:20:57 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting Started with Metro Style Apps book is available for Early Release</title>
		<link>http://blog.tallan.com/2012/04/17/getting-start-with-metro-style-apps-early-release/</link>
		<comments>http://blog.tallan.com/2012/04/17/getting-start-with-metro-style-apps-early-release/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 19:16:05 +0000</pubDate>
		<dc:creator>Ben Dewey</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2282</guid>
		<description><![CDATA[
As many of my friends know I&#8217;ve been working hard on a new book for O&#8217;Reilly called Getting Started with Metro Style Apps.  This book is written for existing .NET developers who are interested in the changes introduced with the release of Windows 8.  This book is intended to be a guide to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://shop.oreilly.com/product/0636920024101.do"><img alt="" src="http://akamaicovers.oreilly.com/images/0636920024101/lrg.jpg" class="alignnone" width="300" /></a></p>
<p>As many of my friends know I&#8217;ve been working hard on a new book for O&#8217;Reilly called <em>Getting Started with Metro Style Apps</em>.  This book is written for existing .NET developers who are interested in the changes introduced with the release of Windows 8.  This book is intended to be a guide to developing complete Metro style apps end-to-end.  If you have an idea or you are just curious about the platform, this is the place to start.</p>
<p>In addition to announcing my cover art (an alligator, yay), I&#8217;m happy to announce that the first few chapters are now available for download via the O&#8217;Reilly Early Release program at <a href="http://shop.oreilly.com/category/early-release.do">http://shop.oreilly.com/category/early-release.do</a>.  You can also see the work in progress and provide feedback via the O&#8217;Reilly Open Feedback Publishing System at <a href="http://ofps.oreilly.com/titles/9781449320553/">http://ofps.oreilly.com/titles/9781449320553/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/04/17/getting-start-with-metro-style-apps-early-release/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New Spatial Features in SQL Server 2012</title>
		<link>http://blog.tallan.com/2012/04/10/new-spatial-features-in-sql-server-2012/</link>
		<comments>http://blog.tallan.com/2012/04/10/new-spatial-features-in-sql-server-2012/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 12:32:17 +0000</pubDate>
		<dc:creator>Lenni Lobel</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Geospatial]]></category>
		<category><![CDATA[Spatial]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2272</guid>
		<description><![CDATA[SQL Server 2012 adds many significant improvements to the spatial support that was first introduced with SQL Server 2008. Among the more notable enhancements is support for curves (arcs), where SQL Server 2008 only supported straight lines, or polygons composed of straight lines. Microsoft also provides methods that test for non-2012-compatible (curved) shapes, and convert [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Server 2012 adds many significant improvements to the spatial support that was first introduced with SQL Server 2008. Among the more notable enhancements is support for curves (arcs), where SQL Server 2008 only supported straight lines, or polygons composed of straight lines. Microsoft also provides methods that test for non-2012-compatible (curved) shapes, and convert circular data to line data for backward compatibility with SQL Server 2008 (as well as other mapping platforms that don’t support curves).</p>
<h3>New Spatial Data Classes</h3>
<p>The three new spatial data classes in SQL Server 2012 are:</p>
<ul>
<li>Circular strings</li>
<li>Compound curves</li>
<li>Curve polygons</li>
</ul>
<p>All three of these shapes are supported in WKT, WKB, and GML by both the <em>geometry</em> and <em>geography</em> data types, and all of the existing methods work on all of the new circular shapes. My previous post, <a href="http://blog.tallan.com/2012/04/09/geospatial-support-for-circular-data-in-sql-server-2012/">Geospatial Support for Circular Data in SQL Server 2012</a> covers these new spatial classes in detail, and shows you how to use them to create circular data. This post focuses on additional spatial features that are new in SQL Server 2012.</p>
<h3>New Spatial Methods</h3>
<p>Let’s explore a few of the new spatial methods. Some of these new methods complement the new curved shapes, while others add new spatial features that work with all shapes.</p>
<h3>The <em>STNumCurves</em> and <em>STCurveN</em> Methods</h3>
<p>These two methods can be invoked on any <em>geometry</em> or <em>geography</em> instance. They can be used together to discover information about the curves contained within the spatial instance. The <em>STNumCurves</em> method returns the total number of curves in the instance. You can then pass any number between 1 and what <em>STNumCurves</em> returns to extract each individual curve, and thus iterate all the curves in the instance.</p>
<p>For example, the WKT string <em>CIRCULARSTRING(0 4, 4 0, 8 4, 4 8, 0 4)</em> defines a perfect circle composed of two connected segments; 0 4, 4 0, 8, 4 and 8 4, 4 8, 0 4 (the third coordinate 8 4 is used both as the ending point of the first arc and the starting point of the second arc. The following code demonstrates how to obtain curve information from this circular string using the <em>STNumCurves</em> and <em>STCurveN</em> methods.</p>
<pre class="brush: plain;">-- Create a full circle shape (two connected semi-circles)
DECLARE @C geometry = 'CIRCULARSTRING(0 4, 4 0, 8 4, 4 8, 0 4)'

-- Get the curve count (2) and the 1st curve (bottom semi-circle)
SELECT
  CurveCount = @C.STNumCurves(),
  SecondCurve = @C.STCurveN(2),
  SecondCurveWKT = @C.STCurveN(2).ToString()</pre>
<p>This query produces the following output:</p>
<pre class="brush: plain;">CurveCount SecondCurve                      SecondCurveWKT
---------- -------------------------------- ------------------------------
2          0x000000000204030000000000000... CIRCULARSTRING (8 4, 4 8, 0 4)</pre>
<p>You can see that <em>STNumCurves</em> indicates there are two curves, and that <em>STCurveN(2)</em> returns the second curve. If you view the results in the spatial viewer, you’ll see just the top half of the circle. This is the semi-circle defined by the second curve, which is converted back to WKT as <em>CIRCULARSTRING (8 4, 4 8, 0 4)</em>. Notice that this represents the second segment of the full circle.</p>
<h3>The <em>BufferWithCurves </em>Method</h3>
<p>SQL Server 2008 introduced the <em>STBuffer</em> method which “pads” a line, effectively converting it into a polygon. If you look closely at the resulting polygon shapes in the spatial viewer, it appears that the points of each line string (including the mid points) are transformed into rounded edges in the polygon. However, the rounded edge look is actually produced by plotting many short straight lines that are clustered very closely together, presenting the illusion of a curve. This approach is necessary since curves were not previously supported before SQL Server 2012 (but the <em>STBuffer</em> method was).</p>
<p>Clearly, using native curve definitions in a curve polygon is more efficient than clustering a multitude of straight lines in an ordinary polygon. For backward compatibility, <em>STBuffer</em> continues to return the (inefficient) polygon as before. So SQL Server 2012 introduces a new method, <em>BufferWithCurves</em>, for this purpose. The following code uses <em>BufferWithCurves</em> to pad lines using true curves, and compares the result with its straight-line cousin, <em>STBuffer</em>.</p>
<pre class="brush: plain;">DECLARE @streets geometry = '
 GEOMETRYCOLLECTION(
  LINESTRING (100 -100, 20 -180, 180 -180),
  LINESTRING (300 -300, 300 -150, 50 -50)
 )'
SELECT @streets.BufferWithCurves(10)

SELECT
  AsWKT = @streets.ToString(),
  Bytes = DATALENGTH(@streets),
  Points = @streets.STNumPoints()
 UNION ALL
 SELECT
  @streets.STBuffer(10).ToString(),
  DATALENGTH(@streets.STBuffer(10)),
  @streets.STBuffer(10).STNumPoints()
 UNION ALL
 SELECT
  @streets.BufferWithCurves(10).ToString(),
  DATALENGTH(@streets.BufferWithCurves(10)),
  @streets.BufferWithCurves(10).STNumPoints()</pre>
<p>Here is the resulting shape returned by the first <em>SELECT</em> statement (the collection of padded line shapes generated by <em>BufferWithCurves</em>):</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/03/pic1.jpg"><img class="alignnone size-full wp-image-1250" src="http://lennilobel.files.wordpress.com/2012/03/pic1.jpg" alt="" width="376" height="302" /></a></p>
<p>As with <em>STBuffer</em>, the new shapes have rounded edges around the points of the original line strings. However, <em>BufferWithCurves</em> generates actual curves, and thus, produces a significantly smaller and simpler polygon. The second <em>SELECT</em> statement demonstrates by comparing the three shapes—the original line string collection, the polygon returned by <em>STBuffer</em>, and the curve polygon returned by <em>BufferWithCurves</em>. Here are the results:</p>
<pre class="brush: plain;">AsWKT                                                        Bytes  Points
-----------------------------------------------------------  -----  ------
GEOMETRYCOLLECTION (LINESTRING (100 -100, 20 -180, 180 -...  151    6
MULTIPOLYGON (((20.000000000000796 -189.99999999999858, ...  5207   322
GEOMETRYCOLLECTION (CURVEPOLYGON (COMPOUNDCURVE ((20.000...  693    38</pre>
<p>The first shape is the original geometry collection of line strings used for input, which requires only 151 bytes of storage, and has only 6 points. For the second shape, <em>STBuffer</em> pads the line strings to produce a multi-polygon (a set of polygons) that consumes 5,207 bytes and has a total of 322 points—a whopping 3,448 percent increase from the original line strings. In the third shape, <em>BufferWithCurves</em> is used to produce the equivalent padding using a collection of curve polygons composed of compound curves, so it consumes only 693 bytes and has only 38 points—a (relatively) mere 458 percent increase from the original line strings.</p>
<h3>The <em>ShortestLineTo </em>Method</h3>
<p>This new method examines any two shapes and figures out the shortest line between them. The following code demonstrates:</p>
<pre class="brush: plain;">DECLARE @Shape1 geometry =
 'POLYGON ((-20 -30, -3 -26, 14 -28, 20 -40, -20 -30))'

DECLARE @Shape2 geometry =
 'POLYGON ((-18 -20, 0 -10, 4 -12, 10 -20, 2 -22, -18 -20))'

SELECT @Shape1
UNION ALL
SELECT @Shape2
UNION ALL
SELECT @Shape1.ShortestLineTo(@Shape2).STBuffer(.25)</pre>
<p>This code defines two polygons and then uses <em>ShortestLineTo</em> to determine, generate, and return the shortest straight line that connects them. <em>STBuffer</em> is also used to pad the line string so that it is more clearly visible in the spatial viewer:</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/03/pic2.jpg"><img class="alignnone size-full wp-image-1251" src="http://lennilobel.files.wordpress.com/2012/03/pic2.jpg" alt="" width="376" height="302" /></a></p>
<h3>The <em>MinDbCompatibilityLevel</em> Method</h3>
<p>With the added support for curves in SQL Server 2012 comes support for backward compatibility with previous versions of SQL Server (2008 and 2008 R2) that don’t support curves. The new <em>MinDbCompatibilityLevel</em> method accepts any WKT string and returns the minimum version of SQL Server required to support the shape defined by that string. For example, consider the following code:</p>
<pre class="brush: plain;">DECLARE @Shape1 geometry = 'CIRCULARSTRING(0 50, 90 50, 180 50)'
DECLARE @Shape2 geometry = 'LINESTRING (0 50, 90 50, 180 50)'

SELECT
 Shape1MinVersion = @Shape1.MinDbCompatibilityLevel(),
 Shape2MinVersion = @Shape2.MinDbCompatibilityLevel()</pre>
<p>The <em>MinDbCompatibilityLevel</em> method returns 110 (referring to version 11.0) for the first WKT string and 100 (version 10.0) for the second one. This is because the first WKT string contains a circular string, which requires SQL Server 2012 (version 11.0), while the line string in the second WKT string is supported by SQL Server 2008 (version 10.0) and higher.</p>
<h3>The <em>STCurveToLine</em> and <em>CurveToLineWithTolerance</em> Methods</h3>
<p>These are two methods you can use to convert curves to roughly equivalent straight line shapes. Again, this is to provide compatibility with previous versions of SQL Server and other mapping platforms that don’t support curves.</p>
<p>The <em>STCurveToLine</em> method converts a single curve to a line string with a multitude of segments and points that best approximate the original curve. The technique is similar to what we just discussed for <em>STBuffer</em>, where many short straight lines are connected in a cluster of points to simulate a curve. And, as explained in that discussion, the resulting line string requires significantly more storage than the original curve. To offer a compromise between fidelity and storage, the <em>CurveToLineWithTolerance</em> method accepts “tolerance” parameters to produce line strings that consume less storage space than those produced by <em>STCurveToLine</em>. The following code demonstrates by using both methods to convert the same circle shape from the previous <em>STNumCurves</em> and <em>STCurveN</em> example into line strings.</p>
<pre class="brush: plain;">-- Create a full circle shape (two connected semi-circles)
DECLARE @C geometry = 'CIRCULARSTRING(0 4, 4 0, 8 4, 4 8, 0 4)'

-- Render as curved shape
SELECT
  Shape = @C,
  ShapeWKT = @C.ToString(),
  ShapeLen = DATALENGTH(@C),
  Points = @C.STNumPoints()

-- Convert to lines (much larger, many more points)
SELECT
  Shape = @C.STCurveToLine(),
  ShapeWKT = @C.STCurveToLine().ToString(),
  ShapeLen = DATALENGTH(@C.STCurveToLine()),
  Points = @C.STCurveToLine().STNumPoints()

-- Convert to lines with tolerance (much smaller, much fewer points)
SELECT
  Shape = @C.CurveToLineWithTolerance(0.1, 0),
  ShapeWKT = @C.CurveToLineWithTolerance(0.1, 0).ToString(),
  ShapeLen = DATALENGTH(@C.CurveToLineWithTolerance(0.1, 0)),
  Points = @C.CurveToLineWithTolerance(0.1, 0).STNumPoints()</pre>
<p>The query results show that the original circle consumes only 112 bytes and has 5 points. Invoking <em>STCurveToLine</em> on the circle converts it into a line string that consumes 1,072 bytes and has 65 points. That’s a big increase, but the resulting line string represents the original circle in high fidelity; you will not see a perceptible difference in the two when viewing them using the spatial viewer. However, the line string produced by <em>CurveToLineWithTolerance</em> consumes only 304 bytes and has only 17 points; a significantly smaller footprint, paid for with a noticeable loss in fidelity. As shown by the spatial viewer results below, using <em>CurveToLineWithTolerance</em> produces a circle made up of visibly straight line segments:</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/03/pic3.jpg"><img class="alignnone size-full wp-image-1252" src="http://lennilobel.files.wordpress.com/2012/03/pic3.jpg" alt="" width="356" height="358" /></a></p>
<h3>The <em>STIsValid</em>, <em>IsValidDetailed</em> and <em>MakeValid</em> Methods</h3>
<p>Spatial instance validation has improved greatly in SQL Server 2012. The <em>STIsValid</em> method evaluates a spatial instance and returns a 1 (for true) or 0 (for false) indicating if the instance represents a valid shape (or shapes). If the instance is invalid, the new <em>IsValidDetailed</em> method will return a string explaining the reason why. The following code demonstrates.</p>
<pre class="brush: plain;">DECLARE @line geometry = 'LINESTRING(1 1, 2 2, 3 2, 2 2)'

SELECT
 IsValid = @line.STIsValid(),
 Details = @line.IsValidDetailed()</pre>
<p>This line string is invalid because the same point (2 2) is repeated, which results in “overlapping edges,” as revealed by the output from <em>IsValidDetailed</em>:</p>
<pre class="brush: plain;">IsValid  Details
-------  -----------------------------------------------------------------
0        24413: Not valid because of two overlapping edges in curve (1).</pre>
<p>SQL Server 2012 is more tolerant of invalid spatial instances than previous versions. For example, you can now perform metric operations (such as <em>STLength</em>) on invalid instances, although you still won’t be able to perform other operations (such as <em>STBuffer</em>) on them.</p>
<p>The new <em>MakeValid</em> method can “fix” an invalid spatial instance and make it valid. Of course, the shape will shift slightly, and there are no guarantees on the accuracy or precision of the changes made. The code in Listing 10-27 uses <em>MakeValid</em> to remove overlapping parts (which can be caused by anomalies such as inaccurate GPS traces), effectively converting the invalid line string into a valid spatial instance.</p>
<pre class="brush: plain;">DECLARE @line geometry = 'LINESTRING(1 1, 2 2, 3 2, 2 2)'
SELECT @line.MakeValid().ToString() AS Fixed</pre>
<p>The WKT string returned by the <em>SELECT</em> statement shows the “fixed” line string:</p>
<pre class="brush: plain;">Fixed
----------------------------------------------------------------
LINESTRING (3 2, 2 2, 1.0000000000000071 1.0000000000000036)</pre>
<h2>Other Enhancements</h2>
<p>The remainder of this post gives brief mention to several other noteworthy spatial enhancements added in SQL Server 2012. These include better <em>geography</em> support, and precision and optimization improvements.</p>
<h3>Support for <em>geography</em> Instances Exceeding a Logical Hemisphere</h3>
<p>Previous versions of SQL Server supported <em>geography</em> objects as large as (slightly less than) a logical hemisphere (half the globe). This limitation has been removed in SQL Server 2012, which now supports <em>geography</em> instances of any size (even the entire planet).</p>
<p>When you define a <em>geography</em> polygon, the order in which you specify the ring’s latitude and longitude coordinates (known as <em>vertex order</em>) is significant (unlike <em>geometry</em>, where vertex order is insignificant). The coordinate points are always defined according to the <em>left-foot inside</em> rule; when you “walk” the boundary of the polygon, your left foot is on the inside. Thus, vertex order determines whether you are defining a small piece of the globe, relative to the larger piece defined by the entire globe <em>except</em> for the small piece (that is, the rest of the globe).</p>
<p>Since previous versions of SQL Server were limited to half the globe, it was impossible to specify the points of a polygon in the “wrong order,” simply because doing so resulted in too large a shape (and thus, raised an error). That error potential no longer exists in SQL Server 2012, so it’s even more critical to make sure your vertex order is correct, or you’ll be unwittingly working with the exact “opposite” shape.</p>
<p>If you have a <em>geography</em> instance that is known have the wrong vertex order, you can repair it using the new <em>ReorientObject</em> method. This method operates only on polygons (it has no effect on points, line strings, or curves), and can be used to correct the ring orientation (vertex order) of the polygon. The following code demonstrates.</p>
<pre class="brush: plain;">-- Small (less than a logical hemisphere) polygon
SELECT geography::Parse(
 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')

-- Reorder in the opposite direction for &quot;rest of the globe&quot;
SELECT geography::Parse(
 'POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 -10))')

-- Reorient back to the small polygon
SELECT geography::Parse(
 'POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 -10))').ReorientObject()</pre>
<p>Three <em>geography</em> polygon instances are defined in this code. The first <em>geography</em> instance defines a very small polygon. The second instance uses the exact same coordinates, but because the vertex order reversed, it defines an enormous polygon whose area represents the entire globe <em>except</em> for the small polygon. As explained, such a definition would cause an error in previous versions of SQL Server, but is now accommodated without a problem by SQL Server 2012. The third instance reverses the vertex order on the same shape as the second instance, thereby producing the same small polygon as the first instance.</p>
<h3>Full Globe Support</h3>
<p>Along with the aforementioned support for <em>geography</em> instances to exceed a single logical hemisphere comes a new spatial data class called <em>FULLGLOBE</em>. As you may have guessed, this is a shape that represents the entire planet. If you’ve ever wondered how many square meters there are in the entire world, the following query gives you the answer (which is 510,065,621,710,996 square meters, so you can stop wondering).</p>
<pre class="brush: plain;">-- Construct a new FullGlobe object (a WGS84 ellipsoid)
DECLARE @Earth geography = 'FULLGLOBE'

-- Calculate the area of the earth
SELECT PlanetArea = @Earth.STArea()</pre>
<p>All of the common spatial methods work as expected on a full globe object. So you could, for example, “cut away” at the globe by invoking the <em>STDifference</em> and <em>STSymDifference</em> method against it using other polygons as cookie-cutter shapes.</p>
<h3>New “Unit Sphere” Spatial Reference ID</h3>
<p>The default spatial reference ID (SRID) in SQL Server 2012 is 4326, which uses the metric system as its unit of measurement. This SRID also represents the true ellipsoidal sphere shape of the earth. While this representation is most accurate, it’s also more complex to calculate precise ellipsoidal mathematics. SQL Server 2012 offers a compromise in speed and accuracy, by adding a new spatial reference id (SRID), 104001, which uses a sphere of radius 1 to represent a <em>perfectly</em> round earth.</p>
<p>You can create <em>geography</em> instances with SRID 104001 when you don’t require the greatest accuracy. The <em>STDistance</em>, <em>STLength</em>, and <em>ShortestLineTo</em> methods are optimized to run faster on the unit sphere, since it takes a relatively simple formula to compute measures against a perfectly round sphere (compared to an ellipsoidal sphere).</p>
<h3>Better Precision</h3>
<p>Internal spatial calculations in SQL Server 2012 are now performed with 48 bits of precision, compared to 27 bits used in SQL Server 2008 and SQL Server 2008 R2. This can reduce the error caused by rounding of floating point coordinates for original vertex points by the internal computation.</p>
<h3>Summary</h3>
<p>This blog post introduced you to some of the powerful new spatial capabilities added to SQL Server 2012. You saw how to use <em>STNumCurves</em> and <em>STCurveN</em> to obtain curve information from circular data, the <em>BufferWithCurves</em> method to produce more efficient padded line shapes than <em>STBuffer</em>, and the <em>ShortestLineTo</em> method to figure out the shortest distance between two shapes. Then you saw how to use the new <em>MinDbCompatibilityLevel</em>, <em>STCurveToLine</em>, and <em>CurveToLineWithTolerance</em> methods for supporting backward compatibility with SQL Server 2008. You also learned how SQL Server 2012 is much better at handling invalid spatial data, using the <em>STIsValid</em>, <em>IsValidDetailed</em>, and <em>MakeValid</em> methods. Finally, you learned about the new full globe support, unit sphere SRID, and improved precision.</p>
<p>You can learn much more about spatial functionality in Tallan&#8217;s new book Programming Microsoft SQL Server 2012, which has an entire chapter dedicated to the topic. I hope you get to enjoy these powerful new spatial capabilities in SQL Server 2012!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/04/10/new-spatial-features-in-sql-server-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geospatial Support for Circular Data in SQL Server 2012</title>
		<link>http://blog.tallan.com/2012/04/09/geospatial-support-for-circular-data-in-sql-server-2012/</link>
		<comments>http://blog.tallan.com/2012/04/09/geospatial-support-for-circular-data-in-sql-server-2012/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 12:24:10 +0000</pubDate>
		<dc:creator>Lenni Lobel</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Circular spatial data]]></category>
		<category><![CDATA[Geospatial]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2268</guid>
		<description><![CDATA[SQL Server 2012 adds many significant improvements to the spatial support that was first introduced with SQL Server 2008. In this blog post, I&#8217;ll explore one of the more notable enhancements: support for curves and arcs (circular data). SQL Server 2008 only supported straight lines, or polygons composed of straight lines. The three new shapes [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Server 2012 adds many significant improvements to the spatial support that was first introduced with SQL Server 2008. In this blog post, I&#8217;ll explore one of the more notable enhancements: support for curves and arcs (circular data). SQL Server 2008 only supported straight lines, or polygons composed of straight lines. The three new shapes in SQL Server 2012 are circular strings, compound curves, and curve polygons. All three are supported in Well-Known Text (WKT), Well-Known Binary (WKB), and Geometry Markup Language (GML) by both the <em>geometry</em> (planar, or &#8220;flat-earth&#8221; model) and <em>geography</em> (ellipsoidal sphere, or geodetic) data types, and all of the existing methods work on the new shapes.</p>
<h3>Circular Strings</h3>
<p>A circular string defines a basic curved line, similar to how a line string defines a straight line. It takes a minimum of three coordinates to define a circular string; the first and third coordinates define the end points of the line, and the second coordinate (the “anchor” point, which lies somewhere between the end points) determines the arc of the line. Here is the shape represented by <em>CIRCULARSTRING(0 1, .25 0, 0 -1):</em></p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/10x21.png"><img class="alignnone size-full wp-image-1157" src="http://lennilobel.files.wordpress.com/2012/01/10x21.png" alt="" width="376" height="302" /></a></p>
<p>The following code produces four circular strings. All of them have the same start and end points, but different anchor points. The lines are buffered slightly to make them easier to see in the spatial viewer.</p>
<pre class="brush: plain;">-- Create a &quot;straight&quot; circular line
SELECT geometry::Parse('CIRCULARSTRING(0 8, 4 0, 8 -8)').STBuffer(.1)
UNION ALL  -- Curve it
SELECT geometry::Parse('CIRCULARSTRING(0 8, 4 4, 8 -8)').STBuffer(.1)
UNION ALL  -- Curve it some more
SELECT geometry::Parse('CIRCULARSTRING(0 8, 4 6, 8 -8)').STBuffer(.1)
UNION ALL  -- Curve it in the other direction
SELECT geometry::Parse('CIRCULARSTRING(0 8, 4 -6, 8 -8)').STBuffer(.1)</pre>
<p>The spatial viewer in SQL Server Management Studio shows the generated shapes:</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/10x22.png"><img class="alignnone size-full wp-image-1158" src="http://lennilobel.files.wordpress.com/2012/01/10x22.png" alt="" width="376" height="302" /></a></p>
<p>The first shape is a “straight circular” line, because the anchor point is position directly between the start and end points. The next two shapes use the same end points with the anchor out to the right (4), one a bit further than the other (6). The last shape also uses the same end points, but specifies an anchor point that curves the line to the left rather than the right (-6).</p>
<p>You can extend circular strings with as many curve segments as you want. Do this by defining another two coordinates for each additional segment. The last point of the previous curve serves as the first end point of the next curve segment, so the two additional coordinates respectively specify the next segment’s anchor and second end point. Thus, valid circular strings will always have an odd number of points. You can extend a circular string indefinitely to form curves and arcs of any kind.</p>
<p>It’s easy to form a perfect circle by connecting two semi-circle segments. For example, the following illustration shows the circle produced by <em>CIRCULARSTRING(0 4, 4 0, 8 4, 4 8, 0 4)</em>.</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/circle.png"><img class="alignnone size-full wp-image-1163" src="http://lennilobel.files.wordpress.com/2012/01/circle.png" alt="" width="376" height="302" /></a></p>
<p>This particular example connects the end of the second segment to the beginning of the first segment to form a closed shape. Note that this is certainly not required of circular strings (or line strings), and that closing the shape by connecting the last segment to the first still does not result in a polygon, which is a two dimensional shape that has area. Despite being closed, this circle is still considered a one-dimensional shape with no area. As you’ll soon see, the curve polygon can be used to convert closed line shapes into true polygons.</p>
<h3>Compound Curves</h3>
<p>A compound curve is a set of circular strings, or circular strings combined with line strings, that form a desired curved shape. The end point of each element in the collection must match the starting point of the following element, so that compound curves are defined in a “connect-the-dots” fashion. The following code produces a compound curve and compares it with the equivalent geometry collection shape.</p>
<pre class="brush: plain;">-- Compound curve
 DECLARE @CC geometry = '
  COMPOUNDCURVE(
   (4 4, 4 8),
   CIRCULARSTRING(4 8, 6 10, 8 8),
   (8 8, 8 4),
   CIRCULARSTRING(8 4, 2 3, 4 4)
  )'

-- Equivalent geometry collection
 DECLARE @GC geometry = '
  GEOMETRYCOLLECTION(
   LINESTRING(4 4, 4 8),
   CIRCULARSTRING(4 8, 6 10, 8 8),
   LINESTRING(8 8, 8 4),
   CIRCULARSTRING(8 4, 2 3, 4 4)
  )'

-- They both render the same shape in the spatial viewer
 SELECT @CC.STBuffer(.5)
 UNION ALL
 SELECT @GC.STBuffer(1.5)</pre>
<p>This code creates a keyhole shape using a compound curve, and also creates an identical shape as a geometry collection (though notice that the <em>LINESTRING</em> keyword is not—and cannot—be specified when defining a compound curve). It then buffers both of them with different padding, so that the spatial viewer clearly shows the two identical shapes on top of one another, as shown:</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/compoundcurve.png"><img class="alignnone size-full wp-image-1164" src="http://lennilobel.files.wordpress.com/2012/01/compoundcurve.png" alt="" width="376" height="302" /></a></p>
<p>Both the compound curve and the geometry collection yield identical shapes. In fact, the expression <em>@CC.STEquals(@GC)</em> which compares the two instances for equality returns 1 (for true). The <em>STEquals</em> method tests for “spatial equality,” meaning it returns true if two instances produce the same shape even if they are being rendered using different spatial data classes. Furthermore, recall that segments of a circular string can be made perfectly straight by positioning the anchor directly between the end points, meaning that the circular string offers yet a third option for producing the very same shape. So which one should you use? Comparing these spatial data classes will help you determine which one is best to use in different scenarios.</p>
<p>A geometry collection (which was already supported in SQL Server 2008) is the most accommodating, but carries the most storage overhead. Geometry collections can hold instances of any spatial data class, and the instances don’t need to be connected to (or intersected with) each other in any way. The collection simply holds a bunch of different shapes as a set, which in this example just happens to be several line strings and circular strings connected at their start and end points.</p>
<p>In contrast, the new compound curve class in SQL Server 2012 has the most constraints but is the most lightweight in terms of storage. It can <em>only</em> contain line strings or circular strings, and each segment’s start point must be connected to the previous segment’s end point (although it is most certainly <em>not</em> necessary to connect the first and last segments to form a closed shape as in this example). The <em>DATALENGTH</em> function shows the difference in storage requirements; <em>DATALENGTH(@CC)</em> returns 152 and <em>DATALENGTH(@GC)</em> returns 243. In our current example, <em>DATALENGTH(@CC)</em> returns 152 and <em>DATALENGTH(@GC)</em> returns 243. This means that the same shape requires 38% less storage space by using a compound curve instead of a geometry collection. A compound curve is also more storage-efficient than a multi-segment circular line string when straight lines are involved. This is because there is overhead for the mere potential of a curve, since the anchor point requires storage even when it’s position produces straight lines, whereas compound curves are optimized specifically to connect circular strings and (always straight) line strings.</p>
<h3>Curve Polygons</h3>
<p>A curve polygon is very similar to an ordinary polygon; like an ordinary polygon, a curve polygon specifies a “ring” that defines a closed shape, and can also specify additional inner rings to define “holes” inside the shape. The only fundamental difference between a polygon and a curve polygon is that the rings of a curve polygon can include circular shapes, whereas an ordinary polygon is composed exclusively with straight lines. Specifically, each ring in a curve polygon can consist of any combination of line strings, circular strings, and compound curves that collectively define the closed shape. For example, the following code produces a curve polygon with the same keyhole outline that I just demonstrated for the compound curve.</p>
<pre class="brush: plain;">-- Curve polygon
 SELECT geometry::Parse('
  CURVEPOLYGON(
   COMPOUNDCURVE(
    (4 4, 4 8),
    CIRCULARSTRING(4 8, 6 10, 8 8),
    (8 8, 8 4),
    CIRCULARSTRING(8 4, 2 3, 4 4)
   )
  )')</pre>
<p>This code has simply specified the same compound curve as the closed shape of a curve polygon. Although the shape is the same, the curve polygon is a two-dimensional object, whereas the compound curve version of the same shape is a one-dimensional object. This can be seen visually by the spatial viewer results, which shades the interior of the curve polygon as shown here:</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/curvepolygon.png"><img class="alignnone size-full wp-image-1165" src="http://lennilobel.files.wordpress.com/2012/01/curvepolygon.png" alt="" width="376" height="302" /></a></p>
<h3>Conclusion</h3>
<p>Circular data support is an important new capability added to the spatial support in SQL Server 2012. In this blog post, I demonstrated the three new spatial data classes for curves and arcs: circular strings, compound curves, and curve polygons. Stay tuned for my next post (coming soon), for more powerful and fun spatial enhancements coming soon in SQL Server 2012!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/04/09/geospatial-support-for-circular-data-in-sql-server-2012/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavascriptHelper–Managing JS files for ASP.NET MVC</title>
		<link>http://blog.tallan.com/2012/03/19/javascripthelpermanaging-js-files-for-asp-net-mvc/</link>
		<comments>http://blog.tallan.com/2012/03/19/javascripthelpermanaging-js-files-for-asp-net-mvc/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 18:32:58 +0000</pubDate>
		<dc:creator>James Curran</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Enterprise .NET]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[User Experience Design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/2012/03/19/javascripthelpermanaging-js-files-for-asp-net-mvc/</guid>
		<description><![CDATA[After working several years with the Castle Monorail MVC framework, I decided to try ASP.NET MVC to see if it had caught up to Monorail. The transition seemed to go rather smoothly, but one area where I was surprised to find how clumsily it was handled, was the management of JavaScript files. Basically, if some [...]]]></description>
			<content:encoded><![CDATA[<p>After working several years with the Castle Monorail MVC framework, I decided to try ASP.NET MVC to see if it had caught up to Monorail. The transition seemed to go rather smoothly, but one area where I was surprised to find how clumsily it was handled, was the management of JavaScript files. Basically, if some part of a page, say a helper or partial page, needed a particular JS file, you had one of two choices.</p>
<p>The first option is to have the part itself would write the script tag. This allows the part to operate as a “black box” – just drop it in and it works – But it means that there will be script tags loading file scattered throughout the page, and that the part needs to know your folder structure where you keep your JavaScript files. And it needs to know if you want the file loaded from you website or from a CDS like Googleapi.com. And, since there’s a good chance it will depend on jQuery, you have to make sure that jquery.js is loaded first, at the top of the page, despite “best Practices” which say script files should be loaded at the bottom of the page. Then, let’s say, two different partial views on the same page use the same JS file, you need a way of making sure it’s only included once. Plus, there’s a good chance it will also depend on its own CSS file being loaded, which doubles the problems above. Microsoft (well, PluralSite’s training videos on Microsoft’s site) recommends putting the script tags in a @section named Scripts, and rendering that in the layout, which helps but only addresses some of the problems)</p>
<p>Alternately, you can break the black box, and manually add the needed script &amp; CSS link tags in your layout. This allows you to group the files tag together in the proper places, CSS at the top, JS at the bottom. But, you must know all the JS files all component of the page need, including all dependencies they have. And if you are putting these in a layout file, then you’ll need to put all the JS files needed for all pages anywhere on the site.</p>
<p>Wouldn’t it be great if there was a way to automatically figure out just the files we need for a certain page, and include just those, without us having to do a lot of thinking about it. Isn’t that the type of thing we invented computers for?</p>
<p>Monorail also lacked such a manager, but Monorail has neither the major corporate sponsor nor the large user community base of ASP.NET MVC, where I figured <i>someone</i> would have written one. I wrote a manager like this for Monorail, so I guess that someone is going to be me… which leads us to the <b>JavascriptHelper.</b></p>
<p><b>Goals:</b></p>
<p>My goals for the JavascriptHelper were the following:</p>
<ul>
<li>To have all needed JS files grouped together, in a single spot I specify (presumably at the bottom of the layout) </li>
<li>To be able to specify a needed JS file in a view, partial view, or helper. </li>
<li>To have all JS files that file depends on included automatically </li>
<li>To have files included only once, regardless of how many pieces requested them. </li>
<li>To be able to specify a block of JS code in a view, partial view or helper and have all the code blocks bundled together. </li>
<li>To be able to say if a code block should be included one per page, or repeatedly. </li>
<li>To be able to associate a needed CSS file, and have it similarly included where I specify in the layout. </li>
<li>To be able to specific a needed file by a simple name. </li>
<li>To be able to easily update the file a particular name refers to (in case where the actual filename includes the version number, like jquery-1.5.1.js </li>
<li>To be able to use one version of a file during development/debugging and easily switch to another (presumably mini-ified) for production. </li>
<li>To be able to use a local version of a file during development/debugging (when I’m often off-line), and easily switch to Google’s CDS for production. </li>
<li>To be able to gather a collection a JS files into a single, combined file (mini-fied on the fly) (OK, the JavascriptHelper doesn’t actually do that, but implementing it would require rewriting only one method &#8212; and adding a controller that handles the actual bundling &amp; mini-fying. We’ll get to that eventually) </li>
</ul>
<p><b>Usage</b></p>
<p>Let’s say for example that I have a partial view that uses the jQuery UI slider control (which I’ll specify some unique id value). Plus it has JS code which needs to be called to initialize it. Say this is in the form of a method and a call to that method using that id. Now, let’s say that we want several sliders on that page, and use that partial view several times, so we’ll only the UI scripts and the method definition once, but we’ll need each separate call to the function. To handle this, you’d need to add to you partial view, the following:</p>
<p><font face="Consolas">Script.Std(&quot;slider&quot;)</font></p>
<p><font face="Consolas">Script.AddScript(&quot;MySlider&quot;,      <br />&quot;function HideSlider(id) { $(id).Hide();}&quot;)</font></p>
<p><font face="Consolas">Script.AddScript(&quot;HideSlider(&#8216;#&quot;+ myId + &quot;&#8217;);&quot;)</font></p>
<p>“Script.Std()” says that “slider” is one of the standard JavaScript files which we have defined what it’s traits and dependencies are. Actually, that could be a comma-separated list of them, so you state everything you need in one line. I originally envisioned only a few “standard” file – jQuery, jQuery UI, et al – but soon realized assigning a keyword for every script file used made life easier. In fact, it will even accept “self” to load a script &amp; CSS file based on the name of the view, i.e., id Script.Std(“self”) is used in /Home/Index, then it will load /Scripts/Views/Home/Index.js and /Content/Css/Home/index.css (if they exist on the file system). How a file is pre-defined, as well as where we get a Script object, will be discussed in the next section. </p>
<p>The first “Script.AddScript()” call defines the function that we need. The second AddScript called calls that function, using the id specific to that instance of the partial view. So, if our page has three instances of this partial view, we’ll need the function definition only once, but the call to it three times. This is handled by given a name to the snippet that need not be repeated. All blocks with the same name are rendered only once (actually, block with the same name as an existing block are ignored, so make sure that you only use a particular name for one script block. )</p>
<p>Then in the Layout, we just add the lines:</p>
<pre>&lt;html&gt;
&lt;head&gt;
@Script.InsertCss();
&lt;/head&gt;
&lt;body&gt;

/* other content for the page */

@Script.InsertScripts();
&lt;/body&gt;
&lt;html&gt;</pre>
<p>This will produce an output of :</p>
<pre>&lt;Html&gt;
&lt;head&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/content/css/ui.base.css&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/content/css/ui.core.css&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/content/css/ui.slider.css&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
/* other content for the page */
&lt;script type=&quot;text/javascript&quot; src=&quot;/Scripts/jquery-1.6.1.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/Scripts/ui/jquery.ui.core.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/Scripts/ui/jquery.ui.widget.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/Scripts/ui/jquery.ui.mouse.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/Scripts/ui/jquery.ui.slider.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
//&lt;![CDATA[
function HideSlider(id) { $(id).Hide();}
HideSlider('#sl12321');
HideSlider('#sl14315');
HideSlider('#sl68953');
//]]&gt;
&lt;/script&gt;&lt;/body&gt;
&lt;html&gt;</pre>
<p><b>Setup:</b></p>
<p>Creating a Script object.</p>
<p>The “Script” object needs to be created differently depending on where it is being used. (You can, of course, call it anything you like. I use “Script” with a capital S, so that it corresponds to @Html).</p>
<p>When used in a view, create it like this:</p>
<p>@{ var Script = StateTheaterMvc.Component.JavascriptHelper.Create(this); }</p>
<p>When used inside a @helper method or an HtmlHelper extension method:</p>
<pre>var script = StateTheaterMvc.Component.JavascriptHelper.Create(WebPageContext.Current);</pre>
<p><b>Configuration XML file</b></p>
<p>Finally, we reach the part which is at the heart of the JavascriptHelper, the jslibraries.xml file. It’s a bit complex, but the default I’ve set up is probably good enough, with perhaps only a few minor tweaks, and once fully configured to your taste, you could easily standardize on that for your whole enterprise. It is, however, simple enough that a NuGet package could be updated it when being added to a project. And the good news is that I’ve also create a XSD schema file for it, so you can have IntelliSense to help you along.</p>
<p>The root element is &lt;libraries&gt; and it has three optional attributes:</p>
<p>“localjspath=” which gives the relative location of the folder where you put your js files. The default is “~/Scripts” which is the ASP.NET MVC default.</p>
<p>“selfJsPath=” which gives the relative location of the folder under which you put your view-specific js files. They follow the same structure as view files, so if you request the js file for /Home/Index, the view file would be /Views/Home/Index.cshtml, and the js file used what be /Scripts/Views/Home/Index.js. Defaults to “~/Script/Views”</p>
<p>“useDebugScripts=” when set to “true” forces use of debug versions of js files when available. Defaults to false. Debug scripts are always used when a debugger is attached.</p>
<pre>&lt;library name=&quot;jquery&quot; version=&quot;1.6.2&quot; useGoogle=&quot;false&quot;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pathname=&quot;jquery-1.6.1.min.js&quot; debugPath=&quot;jquery-1.6.1.js&quot; /&gt;</pre>
<p>Within the &lt;libraries&gt; element, there are a collection of &lt;library&gt; elements – one for each standard javascript file you’ll be using&#8211; which have two required and several optional attributes:</p>
<p>“name=” which gives a unique name for a particular javascript file. It is required and is used by the helper and throughout the xml file to refer to that file.</p>
<p>“pathname=” which gives the path, relative to the localjspath described above, and filename of this file. This can also be a fully-qualified URL if it’s a remote file. It is required. (unless useGoogle</p>
<p>“debugPath=” which, like the pathname attribute, give the relative path to a javascript file to be used when debugging. This is optional and defaults to the value given for the pathname. The idea here is the you set the debugPath to the full, commented version, and the pathname to the mini-fied version, and the helper figures out which to use.</p>
<p>“dependsOn” which is a list of comma separated name of file, which must be loaded before this one. This is the most powerful feature, but also the most confusing, so we’ll expand upon it in a moment. It is optional and defaults to no dependencies</p>
<p>“alias=” which is a list of comma separated alternate names this file could be identified as. I added this because I could never remember if it’s “accordion” or “accordian”. This is optional and defaults to no aliases.</p>
<p>“css=” which gives the name of the css element (see below) associated with this file.</p>
<p>“useGoogle=” which, when set to true, will generate a request to the googleapi.com CDN to load the file. Optional, defaults to false. If true, “version” attribute is required.</p>
<p>“version=” is used only when “useGoogle” is true. Gives the version of the file to load from Google.</p>
<p>Also with the &lt;libraries&gt; element (at the same level as the &lt;library&gt; elements), there is the &lt;css&gt; group.</p>
<p>The &lt;css&gt; element has only one attribute:</p>
<p>“localcsspaath” which gives the relative location of the folder where you put your CSS files. The default is “~/Content” which is the ASP.NET MVC default.</p>
<p>Within the &lt;css&gt; element are multiple &lt;sheet&gt; element, one for each css file associated with a js file. They have two required attributes:</p>
<p>“name=” Unique name used to identified the particular css file. Matches name given in the “css” attribute in the &lt;library&gt; element above. Can be the same as the name used for the js file in the &lt;library&gt; element.</p>
<p>“pathname=” which gives the path, relative to the localcsspath described above, and filename of this file.</p>
<p><b>Example:</b></p>
<pre>&lt;library name=&quot;jquery&quot; version=&quot;1.6.1&quot; useGoogle=&quot;false&quot; pathname=&quot;jquery-1.6.1.min.js&quot;
     debugPath=&quot;jquery-1.6.1.js&quot; /&gt;
&lt;library name=&quot;uicore&quot; dependsOn=&quot;jquery&quot; pathname=&quot;ui/jquery.ui.core.js&quot;/&gt;
&lt;library name=&quot;uiwidget&quot; dependsOn=&quot;uicore&quot; pathname=&quot;ui/jquery.ui.widget.js&quot;/&gt;
&lt;library name=&quot;mouse&quot; dependsOn=&quot;uiwidget&quot; pathname=&quot;ui/jquery.ui.mouse.js&quot;/&gt;
&lt;library name=&quot;datepicker&quot; dependsOn=&quot;uiwidget&quot;
    pathname=&quot;ui/jquery.ui.datepicker.js&quot; css=&quot;ui&quot; /&gt;
&lt;library name=&quot;slider&quot; dependsOn=&quot;uiwidget,mouse&quot;
    pathname=&quot;ui/jquery.ui.slider.js&quot; css=&quot;ui&quot; /&gt;</pre>
<p>&#160;</p>
<p>Starting with the first element, we specified a JavaScript file, which we’ll be calling “jquery”.&#160;&#160; When we ask for “jquery”, we’ll normally get “jquery-1.6.1.min.js” , unless we’re debugging, in which case, it will load “jquery-1.6.1.js”.&#160; It will load these from the website, but, if, as I put it into production, I flip the useGoogle file to true, then it will load it from <a href="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js">http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js</a>&#160; </p>
<p>(Note that the “name” value is used to the URL here.&#160; This is the only place where the actual name used is significant.&#160; Otherwise it can just be any unique string.&#160; This is wrong, and will be fixed in some future release).</p>
<p>Next we want to define the complete componentized version of jQuery UI, so that we can load just the parts we want. First, we declare the UI core as depending on jQuery.&#160; Then we declare widget component as depending on the core.&#160; And the mouse component as depending on the widgets.</p>
<p>Then we can the individual components themselves.&#160; “datepicker” as depending on the widgets; “slider” as depending on the widget &amp; the mouse components.&#160; Since the mouse already depends on widget, it was really necessary to specify both here, but there’s no harm.&#160; So, if you request to use “slider” on your page, then the helper makes sure that jQuery, the UI core, UI Widgets, mouse &amp; slider components are all included, in the proper order.&#160; (Note, there is no checking for circular dependencies, so be careful how you specify the dependsOn attribute)</p>
<p>Both are also associated with the “ui” css file, which brings us to that section:</p>
<pre>&lt;css localcsspath=&quot;~/content/css/Views&quot;&gt;&#160;&#160; &lt;sheet name=&quot;ui&quot; pathname=&quot;ui/themes/Redmond/jquery-ui-1.8.13.custom.css&quot; /&gt;&#160;&#160; &lt;sheet name=&quot;cluetip&quot; pathname=&quot;jquery.cluetip.css&quot; /&gt;</pre>
<p>Both of the jQuery UI components above give “ui” as their CSS file (the theme roller doesn’t create individual CSS files) so if either (or both) is used, that file is included.&#160; CSS files don’t have a separate dependency tree, but all associated CSS files for every dependent js file up the tree are included, so if you wanted to use the separate jQuery UI CSS files, you’d associate&#160; “ui.core.css” with uicode”, “ui.base.css” with “uiwidget” and each component with its own CSS file, and all the needed files will be included.</p>
<p><b>API</b></p>
<p>The API is fairly simple:</p>
<p>Std(string) &#8211; accepts a comma-separated list of script file ids.</p>
<p>AddScript(string id, string script) &#8211; accepts a block of script as text. Multiple calls with the same id are rendered only once.</p>
<p>AddScript(string script) &#8211; accepts a block of script as text. Each call is rendered.</p>
<p>All script from either AddScript methods is rendered in a block at the script insertion point.</p>
<p>AddOnReadyScript(string script) &#8211; accepts a block of script as text. Appended to script run on page ready. All on rendered, wrapped in a jQuery document ready event function, at the point of InsertOnReady()</p>
<p>InsertScripts() &#8212; Renders all script files &amp; script blocks. </p>
<p>InsertOnReady() &#8212; Renders all script block intended for startup, wrapped in a jQuery on ready function.</p>
<p>InsertCss() &#8212; Renders all css files</p>
<p><b>What’s the next step?</b></p>
<p>Now that I’ve made this public, it’s really just a beta. I think there’s still a bit more to be done before it’s ready to be “Production-Ready v1.0”. And I need some feedback….</p>
<p>First of all, how exactly should it be packaged? I’ve been just added to source file to my project, which is simple, but not very elegant. The alternative would be to create an assembly for it, but it’s just one file, so that seem like overkill. I’d really like to create a NuGet package for this, but that question needs to be settled first.</p>
<p>Also, how is the API? Are the method names sufficiently intuitive?</p>
<p>Is an XML file the proper way to store the dependency information?</p>
<p>Is there any feature that really needs to be added?</p>
<p><strong>The code:</strong></p>
<p>The source code is available (under the Apache license) from my GitHub library:</p>
<p><a href="http://github.com/jamescurran/JavascriptHelper">http://github.com/jamescurran/JavascriptHelper</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/03/19/javascripthelpermanaging-js-files-for-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crawling a .netTiers object.</title>
		<link>http://blog.tallan.com/2012/03/14/crawling-a-nettiers-object/</link>
		<comments>http://blog.tallan.com/2012/03/14/crawling-a-nettiers-object/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 22:10:26 +0000</pubDate>
		<dc:creator>Nick Rubino</dc:creator>
				<category><![CDATA[Enterprise .NET]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2214</guid>
		<description><![CDATA[A client project uses a .netTiers data access solution.  Some of my recent tasks involved working with the .netTiers layer of the project to perform copying and auditing of the application data.  Out of the box nettiers offers a convention that gives the ability to crawl through the entire structure of a large object graph. [...]]]></description>
			<content:encoded><![CDATA[<p>A client project uses a .netTiers data access solution.  Some of my recent tasks involved working with the .netTiers layer of the project to perform copying and auditing of the application data.  Out of the box nettiers offers a convention that gives the ability to crawl through the entire structure of a large object graph.  This post describes a generic piece of code I wrote which can perform custom functions on a .netTiers object graph.</p>
<p>All .netTier objects inherit from a base class called EnitityBase which is what gives the ability crawl an object graph.  Going through the following EntityCrawler class will give a better understanding of the importance of the EntityBase.  Here is the code:</p>
<pre class="brush: csharp; wrap-lines: false;">
public class EntityCrawler
{
    private readonly List&lt;EntityBase&gt; _touchedEntities;
    private readonly Func&lt;EntityBase, EntityBase&gt; _processEntity;

    public EntityCrawler(Func&lt;EntityBase, EntityBase&gt; customProcess)
    {
        _touchedEntities = new List&lt;EntityBase&gt;();
        _processEntity = customProcess;
    }

    private static bool IsTypeEntityBase(Type t)
    {
        if (t != null)
        {
            return t == typeof(EntityBase) || IsTypeEntityBase(t.BaseType);
        }
        return false;
    }

    public EntityBase CrawlEntity(EntityBase entity)
    {
        if (entity != null &amp;&amp; !_touchedEntities.Contains(entity))
        {
            _touchedEntities.Add(entity);

            var entityProperties = entity.GetType().GetProperties().Where(pi =&gt;
                IsTypeEntityBase(pi.PropertyType)
            );

            foreach (var subEntity in entityProperties)
            {
                CrawlEntity((EntityBase)subEntity.GetValue(entity,null));
            }

            var collectionProperties = entity.GetType().GetProperties().Where(pi =&gt;
                pi.PropertyType.IsGenericType
                &amp;&amp; pi.PropertyType.GetGenericTypeDefinition() == typeof (TList&lt;&gt;)
                &amp;&amp; IsTypeEntityBase(pi.PropertyType.GetGenericArguments()[0])
            );
            foreach (var collectionProperty in collectionProperties)
            {
                foreach (var subEntity in (IList)collectionProperty.GetValue(entity, null))
                {
                    CrawlEntity((EntityBase)subEntity);
                }
            }
            entity = _processEntity(entity);
        }
        return entity;
    }
}
</pre>
<h2>Code Walk-Through</h2>
<p><span style="text-decoration: underline">Two private class variables (lines 3-4)</span> : <em>_touchedEntities </em>is a list of EntityBases on the object graph that have been hit by the process.  Since there may be points in an object graph where you have a circular relationship, it is very important to check that you have already been to that object otherwise you may end up crawling the graph forever.  <em>_processEntity </em>is a function that takes in and EntityBase and spits out an EntityBase.  This is function is what is performed on each entity in the graph and needs to be provided to the constructor.</p>
<p><span style="text-decoration: underline">Constructor (lines 6-10)</span> : Sets the above variables.</p>
<p><span style="text-decoration: underline">IsTypeEntityBase Method (lines 12-19)</span> : Recursively drills through Type t to find if any of its base types are of type entity base.</p>
<p><span style="text-decoration: underline">CrawlEntity Method (lines 21-51)</span> :</p>
<ol>
<li>Starts off making sure the entity is not null and that it has not been touched yet. If these conditions are true, the entity is added to _touchedEntities and then a list named entityProperties is populated.  EntityProperties contains all the subproperties of type EnityBase on the current entity.  CrawlEntity is then recursively called on each of these entities.</li>
<li>Next a list of named collectionProperties is populated which contains all the sub-properties of the current entity which are of type TList&lt;EntityBase&gt;.  One thing to note, on the last condition “IsTypeEntityBase(pi.PropertyType.GetGenericArguments()[0])”, we know that there is one generic argument because we already know the type is TList&lt;&gt; from the condition before.  Once the collectionProperties are populated, we iterate over each collection and recursively call CrawlEntity on each EntityBase of that collection.</li>
<li>Lastly we call whatever process declared in the constructor on the entity base.</li>
</ol>
<h2>Quick Example</h2>
<p>The following code shows a VERY basic example of using the Entity Crawler.  It goes through the entire entity graph and prints each Type and TrackingKey (a pipe separated string containing the primary key for table the entity models and that key&#8217;s value) of each entity that has been changed since it was loaded from the database.  This example grabs Product 707 from the Microsoft <a href="http://merc.tv/img/fig/AdventureWorks2008.gif">Adventure Works</a> database (with .netTiers built on top of it), changes a few things on the object and then checks for the changes by crawling the entity.  The function passed into the EntityCrawler also changes the color of any EntityBase of type Product.</p>
<pre class="brush: csharp; wrap-lines: false;">
private void runMe()
{
    var provider = new SqlProductProvider(CONN_STRING, false, null);
    var product = provider.GetByProductId(707);
    provider.DeepLoad(product,true);

    product.ProductModelIdSource.CatalogDescription = &quot;DESCRIPTION&quot;;

    Console.WriteLine(string.Format(&quot;The Color before : {0}&quot;, product.Color));
    var ec = new EntityCrawler(CheckForChanges);
    ec.CrawlEntity(product);
    Console.WriteLine(string.Format(&quot;The Color after : {0}&quot;, product.Color));
}

public EntityBase CheckForChanges(EntityBase entity)
{
    if (entity.EntityState == EntityState.Changed)
        Console.WriteLine(string.Format(&quot;You changed something on a(n) {0} object with a trackingkey of {1}.&quot;,
            entity.GetType().Name, entity.EntityTrackingKey));
    if (entity.GetType() == typeof(Product))
        ((Product) entity).Color = &quot;CHANGED_COLOR&quot;;
    return entity;
}
</pre>
<p>Output:</p>
<pre class="brush: plain; wrap-lines: false;">
The Color before : Red
You changed something on a(n) ProductModel object with a trackingkey of ProductModel|33.
The Color after : CHANGED_COLOR
</pre>
<h2>Conclusion</h2>
<p>Obviously there is much more you can do than what is exemplified above.  As long as the function you pass into the constructor takes in an EntityBase and spits out an EntityBase it&#8217;s fair game.  The main value you will get out of this is to perform actions on or query the data in the target EntityBase that may have been changed since the last time you retrieved a copy of it from your database.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/03/14/crawling-a-nettiers-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Spring Application on Azure Cloud</title>
		<link>http://blog.tallan.com/2012/03/09/java-spring-application-on-azure-cloud/</link>
		<comments>http://blog.tallan.com/2012/03/09/java-spring-application-on-azure-cloud/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 21:38:59 +0000</pubDate>
		<dc:creator>Richard Krajunus</dc:creator>
				<category><![CDATA[Architecture and Development]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[How To Guide]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2066</guid>
		<description><![CDATA[Microsoft states to developers using  Azure that one can build applications using any language, tool or framework.  This blog post will show you how to deploy a Spring application on an Azure cloud.  Our first step will be to install a Jetty instance on to the cloud, and then we&#8217;ll import jars and do any [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft states to developers using  Azure that one can build applications using any language, tool or framework.  This blog post will show you how to deploy a Spring application on an Azure cloud.  Our first step will be to install a Jetty instance on to the cloud, and then we&#8217;ll import jars and do any necessary fine tuning to get our sample spring application on the cloud.</p>
<p>There&#8217;s a great blog post to get you started with getting a Jetty instance on the cloud that I want to refer you to: <a href="http://blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspx">http://blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspx</a></p>
<p>Next download a sample spring application.  I was able to get one at: <a href="https://src.springframework.org/svn/spring-samples/petclinic/trunk/">https://src.springframework.org/svn/spring-samples/petclinic/trunk/</a></p>
<p>The presence of a pom.xml file in the root directory tells us that the project can built using maven.  Install maven if you don&#8217;t have it, and then run an mvn clean install from the root directory.  That command will run all unit tests and build the solution.</p>
<p>If I recall, I had a little bit of difficulty with a couple of the tests.  I was able to comment out the failing tests, and the sample application ran fine for our purposes.  Once you get the spring application built, copy the *.war file to the web app dir of your jetty instance.  Startup your jetty instance locally and confirm that the spring app is working.</p>
<p>If the spring application works locally, the next step is to move it to the cloud</p>
<p>Rename your *.war to test.war so that it matches the war from the blog above.  Overwrite the war from above with your new war containing the spring application.  The hardest part about getting a spring application to load instead of just the jetty splash page from the original tutorial is getting your JSP jars in place.  To acquire the JSP jars that were needed I downloaded Jetty 7.4.5.v20110725, and copied the jetty jsp folder (jetty-distribution-7.4.5.v20110725\lib\jsp) to JettyWorkerRole\app\jetty7\lib\jsp and with that your spring application is ready to be deployed to the cloud.</p>
<p>I had a lot of problems putting this tutorial together and generally wouldn&#8217;t recommend a java application on an Azure cloud.  There was tremendous difficulty debugging, because you can&#8217;t access the console that was started by the worker role.  When issues arise, I would just get blank screens in my web browser, and I had to assume (correctly, though I didn&#8217;t know it at the time) the issue was related to jsp jars missing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/03/09/java-spring-application-on-azure-cloud/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Solution: Linked Reports in SSRS Print with Incorrect Size or Orientation</title>
		<link>http://blog.tallan.com/2012/02/29/solution-linked-reports-in-ssrs-print-with-incorrect-size-or-orientation/</link>
		<comments>http://blog.tallan.com/2012/02/29/solution-linked-reports-in-ssrs-print-with-incorrect-size-or-orientation/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 19:14:58 +0000</pubDate>
		<dc:creator>Michael Gerety</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2201</guid>
		<description><![CDATA[Overview
When deploying reports to an SSRS server, the server creates a record in the Catalog table.&#160; this table holds the report location, the binary data for the report, as well as parameter and property information, among other things.&#160; On deployment, various report properties are extracted and added to the Properties column of the Categories table [...]]]></description>
			<content:encoded><![CDATA[<h1>Overview</h1>
<p>When deploying reports to an SSRS server, the server creates a record in the Catalog table.&#160; this table holds the report location, the binary data for the report, as well as parameter and property information, among other things.&#160; On deployment, various report properties are extracted and added to the <strong>Properties</strong> column of the <strong>Categories </strong>table in the <strong>ReportServer</strong> database.&#160; A sample is displayed below:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">Properties</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">Language</span><span style="color: #0000ff">&gt;</span>en-US<span style="color: #0000ff">&lt;/</span><span style="color: #800000">Language</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">HasUserProfileQueryDependencies</span><span style="color: #0000ff">&gt;</span>False<span style="color: #0000ff">&lt;/</span><span style="color: #800000">HasUserProfileQueryDependencies</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">HasUserProfileReportDependencies</span><span style="color: #0000ff">&gt;</span>False<span style="color: #0000ff">&lt;/</span><span style="color: #800000">HasUserProfileReportDependencies</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">PageHeight</span><span style="color: #0000ff">&gt;</span>215.9<span style="color: #0000ff">&lt;/</span><span style="color: #800000">PageHeight</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">PageWidth</span><span style="color: #0000ff">&gt;</span>355.6<span style="color: #0000ff">&lt;/</span><span style="color: #800000">PageWidth</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">TopMargin</span><span style="color: #0000ff">&gt;</span>0<span style="color: #0000ff">&lt;/</span><span style="color: #800000">TopMargin</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">BottomMargin</span><span style="color: #0000ff">&gt;</span>0<span style="color: #0000ff">&lt;/</span><span style="color: #800000">BottomMargin</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">LeftMargin</span><span style="color: #0000ff">&gt;</span>0<span style="color: #0000ff">&lt;/</span><span style="color: #800000">LeftMargin</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">RightMargin</span><span style="color: #0000ff">&gt;</span>0<span style="color: #0000ff">&lt;/</span><span style="color: #800000">RightMargin</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Properties</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>SSRS appears to use the data stored in the P<strong>roperties</strong> column to detect paper size and orientation when printing the report.</p>
<h2>Linked Reports</h2>
<p>When creating a linked report, a new row is created in the <strong>Categories</strong> table, with the <strong>LinkSourceId</strong> column set to the <strong>Id</strong> column of the original report you’re linking from.&#160; The <strong>Properties</strong> column is initialized with the following:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">Properties</span><span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>For some unknown reason, SSRS does not copy over the Properties data.&#160; When printing a linked report, SSRS uses the <strong>Properties</strong> data from the <em>linked report</em>.&#160; Since there is no property data, it uses defaults, generally 8.5&#215;11.&#160; </p>
<h1>Solutions</h1>
<p>Unfortunately, there is no facility in the Report Manager to directly set there properties, so one of the following needs to occur:</p>
<h2>Solution 1: Setting Report Properties Through the ReportService.asmx Web Service</h2>
<p>A post on Brian Weckler’s blog provides VB.NET code for connecting to the ReportService.asmx service and manually setting the properties:</p>
<p><a href="http://blogs.msdn.com/b/bwelcker/archive/2005/09/07/461758.aspx">http://blogs.msdn.com/b/bwelcker/archive/2005/09/07/461758.aspx</a></p>
<p>&#160;</p>
<h2>Solution 2: Updating the Linked Report Record in the Database</h2>
<p>The <strong>property</strong> field can be directly updated in the <strong>catalog </strong>table.</p>
<p>&#160;</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">use</span> ReportServer</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">declare</span> @property <span style="color: #0000ff">varchar</span>(<span style="color: #0000ff">max</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">declare</span> @id uniqueidentifier</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">select</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     @id = ItemID,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     @property = property</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">from</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>     [<span style="color: #0000ff">Catalog</span>]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">where</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>     <span style="color: #0000ff">Path</span> = <span style="color: #006080">'/PathTo/MyReport'</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">update</span> [<span style="color: #0000ff">Catalog</span>]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">set</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>     property = @property</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">where</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span>     LinkSourceId = @id</pre>
<p><!--CRLF--></div>
</div>
<p>If anyone has any better solutions, please let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/02/29/solution-linked-reports-in-ssrs-print-with-incorrect-size-or-orientation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WCF Data Services vs. WCF RIA Services – Making the Right Choice</title>
		<link>http://blog.tallan.com/2012/02/19/wcf-data-services-vs-wcf-ria-services-%e2%80%93-making-the-right-choice/</link>
		<comments>http://blog.tallan.com/2012/02/19/wcf-data-services-vs-wcf-ria-services-%e2%80%93-making-the-right-choice/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 05:38:27 +0000</pubDate>
		<dc:creator>Lenni Lobel</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2188</guid>
		<description><![CDATA[In .NET, Windows Communication Foundation (WCF) provides all the support you need to build distributed service-oriented data access solutions. You can certainly work with WCF directly to create custom services and expose data from an Entity Data Model (EDM) with the ADO.NET Entity Framework, or from any other data access layer (DAL) of your choosing. [...]]]></description>
			<content:encoded><![CDATA[<p>In .NET, Windows Communication Foundation (WCF) provides all the support you need to build distributed service-oriented data access solutions. You can certainly work with WCF directly to create custom services and expose data from an Entity Data Model (EDM) with the ADO.NET Entity Framework, or from any other data access layer (DAL) of your choosing. To take this “raw” approach, you need to start with the basics, or what is commonly referred to as the ABC’s of WCF: Addresses, Bindings, and Contracts. You must create service, operation, and data contracts, and then configure your service model with appropriate endpoint addresses and compatible bindings to be reachable by clients. Services are usually stateless, so you must also handle client-side change tracking and multi-user conflict resolution entirely on your own. The learning curve can be quite steep, after which you will still need to expend a great deal of effort to make it work.</p>
<p>Alternatively, you can turn to one of the two later technologies that Microsoft has built on top of WCF. These are WCF Data Services and WCF RIA Services, and they represent two very different approaches for building data-oriented services. Both provide abstractions that shield you from many underlying WCF particulars, so you get to spend more time focusing on your application and less time on plumbing. For one thing, you don’t need to code WCF contracts or manage change tracking on the client; all that gets done for you. With WCF RIA Services (and Silverlight), you don’t even need to create and update service references; Visual Studio generates code automatically via a special link that keeps your client and WCF RIA Services projects in sync at all times.</p>
<p>Both WCF Data Services and WCF RIA Services can solve many of the same problems, so it is only natural to question which one to use. The answer extends a bit beyond the standard “it depends on your scenario” response, since WCF RIA Services offers a lot more than just data access functionality. It also features client-side self-tracking entities, client-side validation, automatic server-to-client code generation, and more. In this blog post, I&#8217;ll discuss both platforms at a high level to help guide you in making the right choice.</p>
<h2>WCF Data Services</h2>
<p>Microsoft designed WCF Data Services as a thin layer over Entity Framework that exposes data-centric services to client applications. Out of the box, you can quickly build WCF Data Services over an Entity Data Model with virtually no effort. Custom providers for WCF Data Services for data sources other than Entity Framework are available; however, considerable additional effort is required to implement them. You can think of WCF Data Services as universal Web Services built just for data, although it can be easily extended with custom service operation methods. The platform is based on the industry standards of Representational State Transfer (REST) and the Open Data Protocol (OData), which means that these services are consumable by virtually every type of client in the world.</p>
<p>REST provides a uniform interface for querying and updating data. It is based on HTTP, meaning that client requests are issued in the form of GET, POST, MERGE, and DELETE actions — standard verbs understood by all HTTP clients. Any REST query can be invoked with an HTTP GET request by expressing all the elements of the query in a properly formed Uniform Resource Identifier (a URI, which is a more general term than Uniform Resource Locator [URL]). You can even test the service with an ordinary browser; simply type the properly formed URI directly into the address bar and you will receive the Atom Publishing Protocol (AtomPub) response (an XML dialect very similar to the Really Simply Syndication [RSS] feed format). The POST, MERGE, and DELETE verbs correspond respectively to insert, update, and delete operations supported by the service, and the payload (parameters, data, and other metadata) for these operations is passed in HTTP headers.</p>
<p>Just as REST enables universal data access via HTTP, the Open Data Protocol (OData) establishes universal data structure via standard serialization formats (see <a href="http://www.odata.org" target="_blank">http://www.odata.org</a>). All clients can handle plain text formats such as JavaScript Object Notation (JSON) and of course XML, and so OData defines standard response formats based on both formats. JSON provides a compact structure suitable for many basic types of services, while XML forms the basis for the more verbose AtomPub feed format. AtomPub is the default serialization format in WCF Data Services, because it effectively leverages the hierarchical nature of XML to describe the rich structure of data and metadata in an Entity Data Model.</p>
<p>The WCF Data Services client libraries for Windows/WPF, ASP.NET, Silverlight, and Windows Phone 7 include a special LINQ provider, commonly known as LINQ to REST. This provider automatically translates client-side LINQ queries into an equivalent OData URI, meaning that you don’t need to learn the OData URI syntax if you are building Microsoft clients over WCF Data Services (just use good old LINQ). The client libraries automatically deserialize the AtomPub feed response from WCF Data Services into ready-to-use objects. They also provide a stateful context object that can track changes on the client for pushing updates back to the server, although your code needs to explicitly notify the context about objects as they are changed.</p>
<h2>WCF RIA Services</h2>
<p>WCF RIA Services is, well, richer than WCF Data Services (and also newer). Indeed, the R in RIA means rich, although the full TLA (Three-Letter Acronym) can stand for Rich <em>Internet</em> Application or Rich <em>Interactive</em> Application—depending on who you’re talking to. Since its earliest days, WCF RIA Services was designed to work best with Silverlight, although it now also supports OData, SOAP, and JSON to reach a wider range of clients as well. You can build WCF RIA Services over any data access layer, including Entity Framework and LINQ to SQL. You can also use Plain Old CLR Objects (POCOs), in which case you handle the persistence yourself using your data access technique of choice, even conventional ADO.NET (raw readers and command objects, or DataSets). In any case, you expose WCF RIA Services by coding domain service classes that support CRUD operations, as well as other custom service operations. You also maintain a special metadata class for each entity that auto-magically surfaces on the client for effortless end-to-end validation across the wire.</p>
<p>When WCF RIA Services is used with Silverlight, you don’t need to create and update service references; Visual Studio generates code automatically via a special link that keeps your client and WCF RIA Services projects in sync at all times. Like a service reference, this link binds the two projects together, only a WCF RIA Services link couples them much more tightly than an ordinary service reference does. Public changes on the service side are reflected automatically in corresponding classes on the client side every time you perform a build, so you never need to worry about working against an outdated proxy in the client project simply because you forgot to manually update a service reference.</p>
<p>The WCF RIA Services link greatly simplifies the n-tier pattern, and makes traditional n-tier development feel more like the client/server experience. With the link established, Visual Studio continuously regenerates the client-side proxies to match the domain services on each build. It also auto-generates client-side copies of shared application logic you define in the services project, simply by looking for classes you’ve defined in files named *.shared.cs, or *.shared.vb. The link enforces automatic client-side validation and keeps validation rules in sync between the the domain services and the client at all times. Furthermore, client-side entities are completely self-tracking; you do not need to manually notify the context object of every change to every entity, as you are required to do with the WCF Data Services client library.</p>
<h2>Comparing WCF Data Services and WCF RIA Services</h2>
<p>The following table summarizes several key differences between the two platforms.</p>
<table style="border-bottom: 1px solid black" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border-top: 1px solid black;padding-left: 4px;font-weight: bold;background-color: #e0e0e0" valign="top"></td>
<td style="border-top: 1px solid black;padding-left: 4px;font-weight: bold;background-color: #e0e0e0" valign="top">WCF Data Services</td>
<td style="border-top: 1px solid black;padding-left: 4px;font-weight: bold;background-color: #e0e0e0" valign="top">WCF RIA Services</td>
</tr>
<tr>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Supported Clients</td>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Resource-based API, supports all clients via deep REST and OData support.</td>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Domain-based API, most tailored for use with Silverlight, but supports other clients via SOAP, JSON, and OData support.</td>
</tr>
<tr>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Supported Data Access Layers</td>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Targets EF. Other DALs are supported, but greater effort is required.</td>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Supports EF, LINQ to SQL, and POCO (custom persistence layer).</td>
</tr>
<tr>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Client Development</td>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Requires you to notify the context for change tracking.</td>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Supports self-tracking entities, synchronized client/server logic, and much more (particularly with Silverlight).</td>
</tr>
<tr>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Service Development</td>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Instant, code-less, extensible REST services out of the box (with EF); “free CRUD.”</td>
<td style="border-top: 1px solid black;padding-left: 4px" valign="top">Requires you to code CRUD operations manually in domain service classes.</td>
</tr>
</tbody>
</table>
<p>From this comparison, it looks like WCF RIA Services is more attractive for Silverlight clients than non-Silverlight clients—regardless of which data access layer is used. Conversely, it shows that WCF Data Services is more appropriate for use with Entity Framework than it is with other data access layers—regardless of which client is used. But let’s examine things a bit in a bit more detail.</p>
<p>If your scenario uses EF on the back end and targets Silverlight on the front end, then you are in the best position. Both WCF frameworks pack a huge win over writing traditional WCF services “by hand.” Your decision at this point is based on whether you simply require services to provide data access (that is, you primarily need CRUD support), or if are seeking to leverage additional benefits. Another consideration is whether you are targeting Silverlight as the client exclusively or not.</p>
<p>Of the two, WCF Data Services is relatively lightweight, and requires almost no effort to get up and running. So it’s the better choice if you only need data access functionality in your services, particularly if you want to keep your service open to non-Silverlight clients as well. WCF RIA Services is more robust, and offers numerous additional features. This makes it a very compelling choice for the development of rich client applications. Although it began as a platform almost exclusively designed for Silverlight, support is steadily emerging for other client platforms via OData, SOAP, and JSON, as well as self-tracking entity libraries now available for jQuery. However, it requires the effort of creating domain service classes to support CRUD operations.</p>
<p>Finally, both frameworks are extensible, and both can be secured by traditional authentication and authorization techniques. They are also both capable of integrating with the ASP.NET Membership provider for role management and personalization.</p>
<p>What if you are using neither Silverlight nor Entity Framework? Well, then your work will be cut out for you whatever choice you make. With WCF Data Services, you will need to implement either the <a href="http://msdn.microsoft.com/en-us/library/dd723653.aspx" target="_blank">Reflection</a> or <a href="http://msdn.microsoft.com/en-us/library/ee960144.aspx" target="_blank">Streaming</a> provider, or write your own <a href="http://msdn.microsoft.com/en-us/data/gg191846" target="_blank">custom provider</a>. And with WCF RIA Services, you will not get to fully enjoy all the benefits of the framework, but you will still need to write domain services and metadata classes. After careful consideration, you may well conclude that neither choice is appropriate, and decide instead to stick with tried and true WCF services, coding your own service contracts, data contracts, binding configurations, change tracking, validations, and so on.</p>
<h3>Summary</h3>
<p>Both WCF Data Services and WCF RIA Services can represent huge savings in development effort. Which one you choose (or whether indeed you choose to use either) depends a great deal on your data access layer of choice and the types of clients you intend to reach. This post tells you what you need to know to intelligently distinguish between them.</p>
<p>Tallan&#8217;s upcoming book, Programming Microsoft SQL Server 2012, has an entire chapter dedicated to this topic. Look forward to extensive coverage and code samples for complete data access solutions using both platforms. The release date is just a few short months away, so stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/02/19/wcf-data-services-vs-wcf-ria-services-%e2%80%93-making-the-right-choice/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ScrumDashboard V3 in TFS 2010 with SharePoint 2010</title>
		<link>http://blog.tallan.com/2012/02/16/scrumdashboard-v3-in-tfs-2010-with-sharepoint-2010/</link>
		<comments>http://blog.tallan.com/2012/02/16/scrumdashboard-v3-in-tfs-2010-with-sharepoint-2010/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 19:45:32 +0000</pubDate>
		<dc:creator>Michael Gerety</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/2012/02/16/scrumdashboard-v3-in-tfs-2010-with-sharepoint-2010/</guid>
		<description><![CDATA[A few of our teams have been using the EMC (formerly Conchango) Scrum for Team System process template for TFS.&#160; We’re doing a migration at a client over to TFS 2010 from TFS 2008, and were attempting to move to the newest version of the process template along with it.&#160; 
Project Portal Problems
TFS 2010 ships [...]]]></description>
			<content:encoded><![CDATA[<p>A few of our teams have been using the EMC (formerly Conchango) <a href="http://scrumforteamsystem.codeplex.com">Scrum for Team System process template for TFS</a>.&#160; We’re doing a migration at a client over to TFS 2010 from TFS 2008, and were attempting to move to the newest version of the process template along with it.&#160; </p>
<h2>Project Portal Problems</h2>
<p>TFS 2010 ships with integration by default for WSS 3.0 for project portals, with the option to use SharePoint 2010, which we decided to go with.&#160; While the process template comes with a WSS3.0 SharePoint .wsp, the developers had offered an updated version of the .wsp for SharePoint 2010, which was basically a retargeted version of the SharePoint 2007 features.&#160; This resulted in project portals with the old SharePoint 2007 look and feel with a ton of visual issues and errors interspersed throughout.</p>
<h2>Updated SharePoint 2010 .wsp for Scrum for Team System</h2>
<p>After some searching, I found that someone had converted the supplied SharePoint 2010 .WSP and updated it to the new SharePoint 2010 look and feel while repairing all of the issues in the original.</p>
<p>It is available here: <a title="http://www.thecontrarycat.com/2011/07/scrum-for-team-system-v3-and-sharepoint-2010/" href="http://www.thecontrarycat.com/2011/07/scrum-for-team-system-v3-and-sharepoint-2010/">http://www.thecontrarycat.com/2011/07/scrum-for-team-system-v3-and-sharepoint-2010/</a></p>
<p>The screenshot below shows the results:</p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2012/02/image.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 18px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.tallan.com/wp-content/uploads/2012/02/image_thumb.png" width="479" height="271" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/02/16/scrumdashboard-v3-in-tfs-2010-with-sharepoint-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Significant is the SQL Server 2012 Release?</title>
		<link>http://blog.tallan.com/2012/02/05/how-significant-is-the-sql-server-2012-release/</link>
		<comments>http://blog.tallan.com/2012/02/05/how-significant-is-the-sql-server-2012-release/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 21:33:07 +0000</pubDate>
		<dc:creator>Lenni Lobel</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2170</guid>
		<description><![CDATA[SQL Server, particularly its relational database engine, matured quite some time ago. So the “significance” of every new release over recent years can be viewed—in some ways—as relatively nominal. The last watershed release of the product was actually SQL Server 2005, which was when the relational engine (that, for years, defined SQL Server) stopped occupying [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Server, particularly its relational database engine, matured quite some time ago. So the “significance” of every new release over recent years can be viewed—in some ways—as relatively nominal. The last watershed release of the product was actually SQL Server 2005, which was when the relational engine (that, for years, defined SQL Server) stopped occupying “center stage,” and instead took its position alongside a set of services that now, collectively, define the product. These of course include the Business Intelligence (BI) components Reporting Services, Analysis Services, and Integration Services—features that began appearing as early as 1999 but, prior to SQL Server 2005, were integrated sporadically as a patchwork of loosely coupled add-ons, wizards, and management consoles. SQL Server 2005 changed all that with a complete overhaul. For the first time, SQL Server delivered a broader, richer, and more consolidated set of features and services which are built into—rather than bolted onto—the platform. None of the product versions that have been released since that time—SQL Server 2008, 2008 R2, and now 2012—have changed underlying architecture this radically.</p>
<p>That said, each SQL Server release continues to advance itself in vitally significant ways. SQL Server 2008 (released August 6, 2008) added a host of new features to the relational engine—T-SQL enhancements, Change Data Capture (CDC), Transparent Data Encryption (TDE), SQL Audit, FILESTREAM—plus powerful BI capabilities with Excel PivotTables, charts, and CUBE formulas. SQL Server 2008 R2 (released April 21, 2010) was dubbed the “BI Refresh,” adding PowerPivot for Excel, Master Data Services, and StreamInsight, but offering nothing more than minor tweaks and fixes in the relational engine.</p>
<p>The newest release—SQL Server 2012—is set to officially launch on March 7, 2012, and like every new release, this version improves on all of the key “abilities” (availability, scalability, manageability, programmability, and so on). The chief reliability improvement is the new High Availability Disaster Recovery (HADR) alternative to database mirroring. HADR (also commonly known as “Always On”) utilizes multiple secondary servers in an “availability group” for scale-out read-only operations (rather than forcing them to sit idle, just waiting for a failover to occur). Multi-subnet failover clustering is another notable new manageability feature.</p>
<p>SQL Server 2012 adds many new features to the relational engine, most of which are covered in Tallan&#8217;s new book: Programming Microsoft SQL Server 2012 (soon to be published). There are powerful T-SQL extensions, most notably the windowing enhancements, 22 new T-SQL functions, improved error handling, server-side paging, sequence generators, and rich metadata discovery techniques. There are also remarkable improvements for unstructured data, such as the FileTable abstraction over FILESTREAM and the Windows file system API, full-text property searching, and Statistical Semantic Search. Spatial support gets a big boost as well, with support for circular data, full-globe support, increased performance, and greater parity between the geometry and geography data types. Contained databases simplify portability, and new “columnstore” technology drastically increases performance of huge OLAP cubes (with VertiPaq for PowerPivot and Analysis Services) and data warehouses (with similar optimizations implemented in the relational engine).</p>
<p>The aforementioned features are impressive, but still amount to little more than “additives” over an already established database platform. A new release needs more than just extra icing on the cake for customers to perceive an upgrade as compelling. To that end, Microsoft has invested heavily in BI with SQL Server 2012, and the effort shows. The BI portion of the stack has been expanded greatly, delivering key advances in “pervasive insight.” This includes major updates to the product’s analytics, data visualization (such as self-service reporting with Power View), and master data management capabilities, as well Data Quality Services (DQS), a brand new data quality engine. There is also a new Business Intelligence edition of the product that includes all of these capabilities without requiring a full Enterprise edition license. Finally, SQL Server Data Tools (SSDT) brings brand new database tooling inside Visual Studio 2010. SSDT provides a declarative, model-based design-time experience for developing databases while connected, offline, on-premise, or in the cloud.</p>
<p>Of course there are more new features; I’ve only mentioned the most notable ones in this post. Although the relational engine has been rock-solid for several releases, it continues to enjoy powerful enhancements, while the overall product continues to reinvent itself by expanding its stack of services, particularly in the Business Intelligence space.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/02/05/how-significant-is-the-sql-server-2012-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

