<?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>MathLion Software &#187; VB.net</title>
	<atom:link href="http://www.mathlionsoftware.com/topics/devlopment/vbnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mathlionsoftware.com</link>
	<description>The online home for everything MathLion Software</description>
	<lastBuildDate>Mon, 09 Jan 2012 22:14:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>I am finally learning T4&#8230; and it is good!</title>
		<link>http://www.mathlionsoftware.com/2010/10/finally-learning-t4-and-its-good/?source=rss</link>
		<comments>http://www.mathlionsoftware.com/2010/10/finally-learning-t4-and-its-good/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 16:41:44 +0000</pubDate>
		<dc:creator>Mike Hamilton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Link List]]></category>
		<category><![CDATA[T4]]></category>
		<category><![CDATA[VB.net]]></category>
		<category><![CDATA[Code Gen]]></category>
		<category><![CDATA[Text Template]]></category>
		<category><![CDATA[TTTT]]></category>

		<guid isPermaLink="false">http://www.mathlionsoftware.com/?p=118</guid>
		<description><![CDATA[I had heard about T4 (Text Template Transformation Toolkit) templates a while ago, but never really looked into them. But then as I was learning Entity Framework (EF) and the articles on using T4 templates with EF to create POCO (Plain Old CLR Objects) code I read a little on them. I am including links [...]]]></description>
			<content:encoded><![CDATA[<p>I had heard about T4 (Text Template Transformation Toolkit) templates a while ago, but never really looked into them. But then as I was learning Entity Framework (EF) and the articles on using T4 templates with EF to create POCO (Plain Old CLR Objects) code I read a little on them. I am including links to T4 basics at the end of the post.</p>
<p>But then came finding the Silverlight PivotViewer and writing some proof of concept (PoC) stuff for it. I had several large table from a data warehouse we wanted to expose the data in, using the PivotViewer. I did a first go of the PoC app using just a couple columns from one of the tables. But then we wanted to do with the full columns (way overkill, but we wanted to see all the data so we could better determine which ones we&#8217;d want in various PivotViewer Collections). I had designed the app to use classes that wrapped up our Data Layer objects and exposed the fields as new properties that were flagged as Facets using attributes, so the <a href="http://pivotcollectiontools.codeplex.com/" target="_blank">Pivot Collection Tools</a> could be used using the PivotCollection<t> method that the tools offer.</p>
<p> <span id="more-118"></span>I thought that this could be using T4 but as I hadn&#8217;t used it yet, wasn&#8217;t sure where to start. So I did a search online and found a bunch of stuff written by <a href="http://www.olegsych.com/" target="_blank">Oleg Sych</a> about T4. And they all mentioned having two items in addition to standard Visual Studio stuff to make it even easier to work with T4. Those two items are : <a href="http://www.codeplex.com/t4toolbox" target="_blank">T4 toolbox</a> and <a href="http://www.olegsych.com/2009/04/t4-editor-by-tangible-engineering" target="_blank">T4 Editor</a> both of which you can get for free, although there is a Pro version of the Editor available.
<p>Anyways I started my code generation foray using Oleg&#8217;s article titled <a href="http://www.olegsych.com/2008/09/t4-tutorial-creatating-your-first-code-generator/" target="_blank">T4 Tutorial: Creating your first code generator</a> and that got me most of the way to what I needed to do. I did have to do some more learning as the code samples in the article are going against the local server so the code below:</p>
<pre class="brush: vb;">&lt;#
    Dim server as Server = new Server()
    Dim database as Database = new Database(server, "Northwind")
    Dim table as Table = new Table(database, "Products")
    table.Refresh()
#&gt;</pre>
<p>had to be modified as I was hitting the network development DB server and we also use SQL logins and not network authentication so I hoped we could just pass the connection sting to the Server constructor but the string option it looked for was just the server name, and if you needed to do SQL auth then you had to pass to the Server constructor a ServerConnection object. I also had to add a namespace import and reference to an assembly as well. So ended up with the following code:</p>
<pre class="brush: vb;">&lt;#@ assembly name="Microsoft.SqlServer.ConnectionInfo" #&gt;
&lt;#@ import namespace="Microsoft.SqlServer.Management.Common" #&gt;
&lt;#
    'Declare a ServerConnection object variable to specify SQL authentication, login and password.
    Dim conn As New ServerConnection()
    conn.ConnectionString = "Data Source={DBServerName};Persist Security Info=True;User ID={devlogin};Password={devpwd}"
    Dim server As Server = New Server(conn)
    Dim database As Database = New Database(server, "{dbname}")
    Dim table As Table = New Table(database, "{tablename}")
    table.Refresh()
#&gt;
</pre>
<p>And then I modified the template to do what I needed which was fairly easy to so since it is designed to use&nbsp; ASP.NET-like syntax. I save the template and the file is generated for me automatically!</p>
<pre></pre>
<p>Links to basics of T4</p>
<ul>
<li>Microsoft&#8217;s stuff
<ul>
<li>MSDN <a href="http://msdn2.microsoft.com/en-us/library/bb126445.aspx">http://msdn2.microsoft.com/en-us/library/bb126445.aspx</a>
<li>Channel 9 <a href="http://channel9.msdn.com/blogs/vsipmarketing/vsx206-code-generation-with-t4">http://channel9.msdn.com/blogs/vsipmarketing/vsx206-code-generation-with-t4</a> </li>
</ul>
<li>Independent
<ul>
<li>Oleg Sych <a href="http://www.olegsych.com/2007/12/text-template-transformation-toolkit/">http://www.olegsych.com/2007/12/text-template-transformation-toolkit/</a> </li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mathlionsoftware.com/2010/10/finally-learning-t4-and-its-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object and Collection Initializers &#8211; VB.net</title>
		<link>http://www.mathlionsoftware.com/2010/06/object-and-collection-initializers-vb-net/?source=rss</link>
		<comments>http://www.mathlionsoftware.com/2010/06/object-and-collection-initializers-vb-net/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 17:40:54 +0000</pubDate>
		<dc:creator>Mike Hamilton</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Language Feature]]></category>
		<category><![CDATA[VB.net]]></category>

		<guid isPermaLink="false">http://www.mathlionsoftware.com/2010/06/object-and-collection-initializers-vb-net/</guid>
		<description><![CDATA[While doing some work on some DTO (Data Transfer Objects) code and I decided instead of making numerous overloads of the constructor for an object, I would provide basic one or two and additional construction options when using them will use the new Object Initializer code structure available.
I was looking for a good set of [...]]]></description>
			<content:encoded><![CDATA[<p>While doing some work on some DTO (Data Transfer Objects) code and I decided instead of making numerous overloads of the constructor for an object, I would provide basic one or two and additional construction options when using them will use the new Object Initializer code structure available.</p>
<p>I was looking for a good set of examples and the below blog post is pretty good so I am linking it here for me to find later.</p>
<p><a href="http://blogs.msdn.com/b/ericwhite/archive/2008/11/24/object-and-collection-initializers-vb.aspx">Object and Collection Initializers &#8211; VB &#8211; Eric White&#8217;s Blog &#8211; Site Home &#8211; MSDN Blogs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mathlionsoftware.com/2010/06/object-and-collection-initializers-vb-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

