<?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>Avivo Tech Blog &#187; generator</title>
	<atom:link href="http://tech.avivo.si/tag/generator/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.avivo.si</link>
	<description>Solving problems</description>
	<lastBuildDate>Tue, 24 Jan 2012 14:46:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Create Linq to SQL classes from .sdf (Local database)</title>
		<link>http://tech.avivo.si/2010/03/create-linq-to-sql-classes-from-sdf-local-database/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-linq-to-sql-classes-from-sdf-local-database</link>
		<comments>http://tech.avivo.si/2010/03/create-linq-to-sql-classes-from-sdf-local-database/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 18:53:00 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[code generator]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[sdf]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=462</guid>
		<description><![CDATA[Linq allows to handle data easily. Linq to SQL tools are integrated in Visual Studio but is limited to can generate code only for  certain databases. To create ORM from .sdf database file read on&#8230; What to do? Copy next script to a file with .bat extension. Change DATABASE_NAME, DATABASE_PASSWORD and NAMESPACE according to your [...]]]></description>
			<content:encoded><![CDATA[<p>Linq allows to handle data easily. Linq to SQL tools are integrated in Visual Studio but is limited to can generate code only for  certain databases. To create ORM from .sdf database file read on&#8230;</p>
<p><strong>What to do?</strong><br />
Copy next script to a file with <em>.bat</em> extension.</p>
<p>Change <em>DATABASE_NAME</em>,<em> DATABASE_PASSWORD </em>and <em>NAMESPACE </em>according to your needs.</p>
<pre class="batch">@echo off
rem Input parameters
rem DATABASE_NAME should NOT contain spaces
set DATABASE_NAME=MyDatabase
set DATABASE_PASSWORD=mypass
set NAMESPACE=MyNamespace.Database

rem Set full path to SqlMetal.exe
rem For 64-bit Windows
set SQLMETAL="%ProgramW6432%\Microsoft SDKs\Windows\v6.0A\Bin\SqlMetal.exe"
rem For 32-bit Windows
if "%ProgramW6432%"=="" set SQLMETAL="%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bin\SqlMetal.exe"

rem Other parameters
set DATABASE_PATH="%CD%\%DATABASE_NAME%.sdf"
set OUTPUT_CS_PATH="%CD%\%DATABASE_NAME%.cs"
set OUTPUT_DBML_PATH="%CD%\%DATABASE_NAME%.dbml"
set CONNECTION_STRING="Data Source=\"%DATABASE_PATH%\"; Password=\"%DATABASE_PASSWORD%\";"

rem Check and run sqlmetal
if not exist %SQLMETAL% goto error-missing-sqlmetal
%SQLMETAL% /conn:%CONNECTION_STRING% /dbml:%OUTPUT_DBML_PATH% /namespace:%NAMESPACE% /context:%DATABASE_NAME%DataContext /pluralize
%SQLMETAL% /conn:%CONNECTION_STRING% /code:%OUTPUT_CS_PATH% /namespace:%NAMESPACE% /context:%DATABASE_NAME%DataContext /pluralize
goto end

:error-missing-sqlmetal
echo Error: cannot find sqlmetal.exe
echo Search location: %SQLMETAL%
goto end

:end</pre>
<p><strong>Example</strong></p>
<p>If the database is stored in <em>C:\db\Website.sdf</em> then copy script into <em>C:\db\make.bat</em>. Change <em>DATABASE_NAME</em> to <em>Website </em>and run the script. Script should generate <em>C:\db\Website.cs</em> and <em>C:\db\Website.dbml</em> files. Include the generated <em>.cs</em> file into your project.</p>
<p><strong>Using the generated code</strong></p>
<pre class="c-sharp">class Program
{
  static void Main()
  {
    //Suppose that Website.sdf has Page table with CreationDate column of type DateTime
    WebsiteDataContext db = new WebsiteDataContext(@"C:\db\Website.sdf");
    var list = from p in db.Pages
                 where p.CreationDate &gt; DateTime.Today
                 selet p;

    //Show number of pages that match Linq query
    Console.WriteLine(list.Count() + " pages created today.");
  }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/03/create-linq-to-sql-classes-from-sdf-local-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Number list generator</title>
		<link>http://tech.avivo.si/2009/04/number-list-generator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=number-list-generator</link>
		<comments>http://tech.avivo.si/2009/04/number-list-generator/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 08:53:56 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[listing]]></category>
		<category><![CDATA[number generator]]></category>
		<category><![CDATA[number list generator]]></category>
		<category><![CDATA[order number]]></category>
		<category><![CDATA[sequence]]></category>
		<category><![CDATA[sequence generator]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=54</guid>
		<description><![CDATA[For example you want to produce a text file with all the integers in order from 1 to 2000, and have the file named &#8220;List2000.txt&#8221; your command line would look like this: Start DOS prompt. Type: C:\&#62;for /L %i in (1,1,2000) do @echo %i &#62;&#62;List2000.txt The three integers (no fractions!) within the parentheses are start, [...]]]></description>
			<content:encoded><![CDATA[<p>For example you want to produce a text file with all the integers in order from 1 to 2000, and have the file named &#8220;List2000.txt&#8221; your command line would look like this:</p>
<ul>
<li>Start DOS prompt.</li>
<li> Type:<br />
<strong>C:\&gt;for /L %i in (1,1,2000) do @echo %i &gt;&gt;List2000.txt</strong></li>
<li>The three integers (no fractions!) within the parentheses are start, step, and end numbers. Here we start with 1, go by steps of 1, till we hit 2000, and write the file.</li>
<li>Hit &lt;ENTER&gt;. The computer chugs for a few seconds, and generates the file.</li>
<li>To go backwards from 100 to 0 by step 2, the command line would read:<strong><br />
C:\&gt;for /L %i in (100,-2,0) do @echo %i &gt;&gt;List-100a.txt</strong></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/04/number-list-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

