<?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>Olaf's Thoughts About Development &#187; LINQ</title>
	<atom:link href="http://www.monien.net/blog/index.php" rel="self" type="application/rss+xml" />
	<link>http://www.monien.net/blog</link>
	<description>Delphi Programming, .NET Philosophy, Web development and more ...</description>
	<lastBuildDate>Mon, 14 Mar 2011 15:59:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Delphi can even LINQ to SQL!</title>
		<link>http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/</link>
		<comments>http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 15:04:02 +0000</pubDate>
		<dc:creator>Olaf Monien</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[Delphi Prism]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[LINQ to SQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.monien.net/blog/?p=225</guid>
		<description><![CDATA[As there is obviously still some uncertainty if Delphi Prism is really a fully fledged .NET development environment, I&#8217;m posting an example below to prove that Prism does allow you to LINQ to SQL: This is a &#8220;Customer&#8221; class definition with a manual mapping to a &#8220;Customers&#8221; table on a SQL Server 2005: type [Table(Name [...]]]></description>
			<content:encoded><![CDATA[<p>As there is obviously still some uncertainty if Delphi Prism is really a fully fledged .NET development environment, I&#8217;m posting an example below to prove that Prism does allow you to LINQ to SQL:</p>
<p>This is a &#8220;Customer&#8221; class definition with a manual mapping to a  &#8220;Customers&#8221; table on a SQL Server 2005:</p>
<pre class="brush: delphi">

type
[Table(Name := &#039;Customers&#039;)]
Customer = class(Object)
private
protected
public
[Column(IsPrimaryKey := true)]
property CustNo:Double;
[Column]
property Name: String;
[Column]
property Country: String;
end;
</pre>
<p>This is the actual LINQ to SQL code that relies on the class definition above:</p>
<pre class="brush: delphi">

method MainForm.button2_Click(sender: System.Object; e: System.EventArgs);
var
LCustomers: Table&lt;Customer&gt;;
LDBMain: DataContext;
LConnectionString:String;
begin
LConnectionString := &#039;Data Source=.\SQLEXPRESS;Initial Catalog=DBDEMOS;Integrated Security=True&#039;;
LDBMain := new DataContext(LConnectionString);
LCustomers := LDBMain.GetTable&lt;Customer&gt;();
var USCustomers := from Customer in LCustomers where Customer.Country = &#039;US&#039; select Customer;

for each Customer in USCustomers do begin
listBox1.Items.Add(Customer.Name);
end;
end;
</pre>
<p>Interesting to note is that Prism has a very nice name scope mechanism. Even though &#8220;Customer&#8221; is a Class name, it is also used as local variable in the LINQ and FOR constructs. I am not saying that this is a good practice though <img src='http://www.monien.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Technically, both &#8220;Customer&#8221; variables are <em>different</em> variables &#8211; which is quite important to understand.</p>
<p>The full demo source can be downloaded here: [download#2].</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+can+even+LINQ+to+SQL%21&amp;link=http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/&amp;notes=As%20there%20is%20obviously%20still%20some%20uncertainty%20if%20Delphi%20Prism%20is%20really%20a%20fully%20fledged%20.NET%20development%20environment%2C%20I%27m%20posting%20an%20example%20below%20to%20prove%20that%20Prism%20does%20allow%20you%20to%20LINQ%20to%20SQL%3A%0D%0A%0D%0AThis%20is%20a%20%22Customer%22%20class%20definition%20with%20a%20manual%20mapping%20to%20a%20%20%22Customers%22%20table%20on%20a%20SQL%20Server%20&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+can+even+LINQ+to+SQL%21&amp;link=http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/&amp;notes=As%20there%20is%20obviously%20still%20some%20uncertainty%20if%20Delphi%20Prism%20is%20really%20a%20fully%20fledged%20.NET%20development%20environment%2C%20I%27m%20posting%20an%20example%20below%20to%20prove%20that%20Prism%20does%20allow%20you%20to%20LINQ%20to%20SQL%3A%0D%0A%0D%0AThis%20is%20a%20%22Customer%22%20class%20definition%20with%20a%20manual%20mapping%20to%20a%20%20%22Customers%22%20table%20on%20a%20SQL%20Server%20&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+can+even+LINQ+to+SQL%21&amp;link=http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/&amp;notes=As%20there%20is%20obviously%20still%20some%20uncertainty%20if%20Delphi%20Prism%20is%20really%20a%20fully%20fledged%20.NET%20development%20environment%2C%20I%27m%20posting%20an%20example%20below%20to%20prove%20that%20Prism%20does%20allow%20you%20to%20LINQ%20to%20SQL%3A%0D%0A%0D%0AThis%20is%20a%20%22Customer%22%20class%20definition%20with%20a%20manual%20mapping%20to%20a%20%20%22Customers%22%20table%20on%20a%20SQL%20Server%20&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=3&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+can+even+LINQ+to+SQL%21&amp;link=http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/&amp;notes=As%20there%20is%20obviously%20still%20some%20uncertainty%20if%20Delphi%20Prism%20is%20really%20a%20fully%20fledged%20.NET%20development%20environment%2C%20I%27m%20posting%20an%20example%20below%20to%20prove%20that%20Prism%20does%20allow%20you%20to%20LINQ%20to%20SQL%3A%0D%0A%0D%0AThis%20is%20a%20%22Customer%22%20class%20definition%20with%20a%20manual%20mapping%20to%20a%20%20%22Customers%22%20table%20on%20a%20SQL%20Server%20&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=257&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+can+even+LINQ+to+SQL%21&amp;link=http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/&amp;notes=As%20there%20is%20obviously%20still%20some%20uncertainty%20if%20Delphi%20Prism%20is%20really%20a%20fully%20fledged%20.NET%20development%20environment%2C%20I%27m%20posting%20an%20example%20below%20to%20prove%20that%20Prism%20does%20allow%20you%20to%20LINQ%20to%20SQL%3A%0D%0A%0D%0AThis%20is%20a%20%22Customer%22%20class%20definition%20with%20a%20manual%20mapping%20to%20a%20%20%22Customers%22%20table%20on%20a%20SQL%20Server%20&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+can+even+LINQ+to+SQL%21&amp;link=http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/&amp;notes=As%20there%20is%20obviously%20still%20some%20uncertainty%20if%20Delphi%20Prism%20is%20really%20a%20fully%20fledged%20.NET%20development%20environment%2C%20I%27m%20posting%20an%20example%20below%20to%20prove%20that%20Prism%20does%20allow%20you%20to%20LINQ%20to%20SQL%3A%0D%0A%0D%0AThis%20is%20a%20%22Customer%22%20class%20definition%20with%20a%20manual%20mapping%20to%20a%20%20%22Customers%22%20table%20on%20a%20SQL%20Server%20&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=10&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

