<?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>THE .NET WAY &#187; SQLServer</title>
	<atom:link href="http://www.thedotnetway.net/tag/sqlserver/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedotnetway.net</link>
	<description>El blog Tecnológico de Emilio Torrens y Jordi Cladera</description>
	<lastBuildDate>Thu, 29 Jul 2010 08:27:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Persistencia de Objetos con XPO</title>
		<link>http://www.thedotnetway.net/2010/07/29/persistencia-de-objetos-con-xpo/</link>
		<comments>http://www.thedotnetway.net/2010/07/29/persistencia-de-objetos-con-xpo/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 08:18:22 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Herramientas]]></category>
		<category><![CDATA[RAD]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://www.thedotnetway.net/2010/07/29/persistencia-de-objetos-con-xpo/</guid>
		<description><![CDATA[Estos días estoy probando varias soluciones de persistencia de Objetos ya que estoy pensando seriamente dejar de usar Deklarit porque van muy lentos con las versiones. El primero que he probado ha sido XPO de DevExpress, es bastante potente y fácil de usar aunque el generador de clases desde una BD existente es un poco [...]]]></description>
			<content:encoded><![CDATA[<p><img style="margin: 0px 5px 0px 0px; display: inline;" src="http://boxcabi.files.wordpress.com/2010/01/devexpress.jpg" alt="" width="164" height="82" align="left" />Estos días estoy probando varias soluciones de persistencia de Objetos ya que estoy pensando seriamente dejar de usar <a href="http://www.deklarit.com" target="_blank">Deklarit</a> porque van muy lentos con las versiones.</p>
<p>El primero que he probado ha sido <a href="http://www.devexpress.com/Products/NET/ORM/" target="_blank">XPO</a> de <a href="http://www.devexpress.com/" target="_blank">DevExpress</a>, es bastante potente y fácil de usar aunque el generador de clases desde una BD existente es un poco pobre, no te genera las relaciones ni las tablas cuya PK este compuesta por varios campos, eso tendremos que solucionarlo a mano, aquí podéis ver como.</p>
<p>El tema de PK por múltiples campos se soluciona creando una estructura donde definimos la clave primaria y luego en la clase que mapeamos a la tabla definimos esa estructura como PK</p>
<div id="codeSnippetWrapper">
<div id="codeSnippetWrapper" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">struct</span> MyTablePK</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    [Persistent(<span style="color: #006080;">"Field1"</span>)]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> FieldKey1;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    [Persistent(<span style="color: #006080;">"Field2"</span>)]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> FiledKey2;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">}</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">[OptimisticLocking(<span style="color: #0000ff;">false</span>)]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">[Persistent(<span style="color: #006080;">"Table"</span>)]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> MyTable : XPBaseObject</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    [Key(), Persistent()]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> MyTablePK PK;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Field3;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Field4;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> MyTable(Session session) : <span style="color: #0000ff;">base</span>(session) { }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> MyTable() : <span style="color: #0000ff;">base</span>(Session.DefaultSession) { }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> AfterConstruction() { <span style="color: #0000ff;">base</span>.AfterConstruction(); }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">}</pre>
<p><!--CRLF--></p>
</div>
</div>
</div>
<p>El tema de la relaciones se soluciona utilizando el atributo [Association] en la propiedad donde definimos la colección de objetos hijos indicándole el nombre que le hemos dado en el SQL al FK</p>
<div id="codeSnippetWrapper" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">[OptimisticLocking(<span style="color: #0000ff;">false</span>)]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">[Persistent(<span style="color: #006080;">"Table"</span>)]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> MyTable : XPBaseObject</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    [Key(<span style="color: #0000ff;">true</span>)]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> PK;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Field1;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Field2;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    [Association(<span style="color: #006080;">"Table-ChildTable"</span>, <span style="color: #0000ff;">typeof</span>(MyChildTable)), Aggregated]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> XPCollection Childs</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    {</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        get { <span style="color: #0000ff;">return</span> GetCollection(<span style="color: #006080;">"MyChildTable"</span>); }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> MyTable(Session session) : <span style="color: #0000ff;">base</span>(session) { }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> MyTable() : <span style="color: #0000ff;">base</span>(Session.DefaultSession) { }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> AfterConstruction() { <span style="color: #0000ff;">base</span>.AfterConstruction(); }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">}</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">[OptimisticLocking(<span style="color: #0000ff;">false</span>)]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">[Persistent(<span style="color: #006080;">"ChilTable"</span>)]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> MyChildTable : XPBaseObject</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> FK;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> PK;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Field1;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> Field2;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> MyChildTable(Session session) : <span style="color: #0000ff;">base</span>(session) { }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> MyChildTable() : <span style="color: #0000ff;">base</span>(Session.DefaultSession) { }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> AfterConstruction() { <span style="color: #0000ff;">base</span>.AfterConstruction(); }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">}</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Pues nada, sigo probando cosas, ya iré comentando <img src='http://www.thedotnetway.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2010/07/29/persistencia-de-objetos-con-xpo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP y Windows</title>
		<link>http://www.thedotnetway.net/2009/05/13/php-y-windows/</link>
		<comments>http://www.thedotnetway.net/2009/05/13/php-y-windows/#comments</comments>
		<pubDate>Wed, 13 May 2009 10:26:59 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://www.thedotnetway.net/2009/05/13/php-y-windows/</guid>
		<description><![CDATA[No por programar en PHP tienes que estar casado con Linux pero la verdad es que eso es lo que suele pasar, nosotros mismos hemos tenido proyectos con la parte servidora corriendo en Windows, SQLServer e IIS y el UI en PHP en Linux obligando al cliente a mantener dos tipos de servidores con los [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thedotnetway.net/wp-content/uploads/2009/05/php-lab.png"><img title="php_lab" style="border-top-width: 0px; display: inline; border-left-width: 1px; border-bottom-width: 0px; margin-left: 0px; margin-right: 0px; border-right-width: 0px" height="95" alt="php_lab" src="http://www.thedotnetway.net/wp-content/uploads/2009/05/php-lab-thumb.png" width="95" align="left" border="0" /></a> </p>
<p>No por programar en <a href="http://es.wikipedia.org/wiki/.php" target="_blank">PHP</a> tienes que estar casado con Linux pero la verdad es que eso es lo que suele pasar, nosotros mismos hemos tenido proyectos con la parte servidora corriendo en Windows, SQLServer e IIS y el UI en PHP en Linux obligando al cliente a mantener dos tipos de servidores con los problemas y gastos que puede generar eso.</p>
<p>El otro día ya estuve escribiendo sobre las ventajas del PHP, rápido y sencillo (por no hablar de la cantidad de programadores que puedes encontrar), por lo que no es descabellado plantear un proyecto con el UI en web en PHP mientras toda la parte servidora la tienes en .NET, con SQLServer como base de datos e IIS como servidor de aplicaciones.</p>
<p>La gente de Microsoft ha preparado un KIT de entrenamiento para los programadores de PHP, en este KIT tienes ejemplos y documentación para usar IIS y SQLServer desde PHP, lo puedes <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=c8498c9b-a85a-4afa-90c0-593d0e4850cb" target="_blank">descargar desde aquí</a> y encontraras:</p>
<p>PHP &amp; SQL Server Demos.    <br />Integrating SQL Server Geo-Spatial with PHP.     <br />SQL Server Reporting Services and PHP.     <br />PHP &amp; SQL Server Hands On Labs.     <br />Introduction to Using SQL Server with PHP.     <br />Using Full Text Search over Office Documents in PHP.     <br />PHP on Windows Hands On Labs.     <br />IIS Access Control Features for PHP.     <br />Using IIS 7.0 Media Features in a PHP Application.     <br />Troubleshooting PHP.     <br />Migrating PHP Applications to IIS 7.0. </p>
<p>A disfrutarlo <img src='http://www.thedotnetway.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />     </p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2009/05/13/php-y-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQ to SQL, orderby y Take</title>
		<link>http://www.thedotnetway.net/2009/05/12/linq-to-sql-orderby-y-take/</link>
		<comments>http://www.thedotnetway.net/2009/05/12/linq-to-sql-orderby-y-take/#comments</comments>
		<pubDate>Tue, 12 May 2009 08:17:40 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[SQLServer]]></category>
		<category><![CDATA[Trucos]]></category>

		<guid isPermaLink="false">http://www.thedotnetway.net/2009/05/12/linq-to-sql-orderby-y-take/</guid>
		<description><![CDATA[Con LINQ 2 SQL y usando Take, es realmente sencillo obtener los últimos o los primeros registros de una Tabla, simplemente tenemos que ordenarla como nos interese con el order by y usar el método Take para indicar cuantos registros queremos. Aquí dejo un ejemplo para coger los últimos registros de una tabla. public List&#60;object&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Con <a href="http://es.wikipedia.org/wiki/Language_Integrated_Query" target="_blank">LINQ 2 SQL</a> y usando <a href="http://msdn.microsoft.com/es-es/library/bb503062(VS.95).aspx" target="_blank">Take</a>, es realmente sencillo obtener los últimos o los primeros registros de una Tabla, simplemente tenemos que ordenarla como nos interese con el <a href="http://msdn.microsoft.com/es-es/library/bb534966(VS.95).aspx" target="_blank">order by</a> y usar el método Take para indicar cuantos registros queremos.</p>
<p>Aquí dejo un ejemplo para coger los últimos registros de una tabla.</p>
</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ddad6b19-9951-4864-b69d-9b997d401d63" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">   </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> List</span><span style="color: #000000;">&lt;</span><span style="color: #0000FF;">object</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> GetLastRecords(</span><span style="color: #0000FF;">int</span><span style="color: #000000;"> NoOfRecords)
        {
            var records </span><span style="color: #000000;">=</span><span style="color: #000000;">
                (from r </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> DataClassesDataContext.Table
                 orderby r.Pk descending select r).Take(NoOfRecords);

            List</span><span style="color: #000000;">&lt;</span><span style="color: #0000FF;">object</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> Result </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> List</span><span style="color: #000000;">&lt;</span><span style="color: #0000FF;">object</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">();

            </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (Record record </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> records)
            {
                Result.Add(records);
            }

            </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> Result;
        }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2009/05/12/linq-to-sql-orderby-y-take/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLServer 2008 Disponible</title>
		<link>http://www.thedotnetway.net/2008/09/24/sqlserver-2008-disponible/</link>
		<comments>http://www.thedotnetway.net/2008/09/24/sqlserver-2008-disponible/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 13:43:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2008/09/24/sqlserver-2008-disponible/</guid>
		<description><![CDATA[Me acaba de llegar el mail desde MS, SQL Server 2008 ya esta disponible El pasado 6 de Agostoanunciaban la RTM (Release to Manufacturing) de Microsoft SQL Server 2008. ¡Y ya está disponible para que tus clientes puedan sacarle todo el partido! Es una plataforma de datos fiable, productiva e inteligente con la cual ya [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>Me acaba de llegar el mail desde MS, SQL Server 2008 ya esta disponible <img src='http://www.thedotnetway.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img src="http://www.thedotnetway.net/content/binary/SQLServer2008.jpg" border="0" /></p>
<p>El pasado 6 de Agostoanunciaban la RTM (Release to Manufacturing) de Microsoft SQL Server 2008. ¡Y ya está disponible para que tus clientes puedan sacarle todo el partido!   <br />Es una plataforma de datos fiable, productiva e inteligente con la cual ya pueden gestionar las aplicaciones de misión crítica más exigentes, reducir el tiempo y el coste tanto de desarrollo como de administración y facilitar la información necesaria de forma más ágil para la toma de decisiones.</p>
<p>Ahora con SQL Server 2008 podrán gestionar cualquier tipo de dato, en cualquier sitio y en cualquier momento: datos espaciales, imágenes, música y archivos gestionados de forma coherente, integrada y segura.</p>
<p>Ediciones de SQL Server 2008:    <br />Además de las ya existentes con SQL Server 2005 (Enterprise, Standard, Workgroup, Developer, Express y Compact), con el lanzamiento de SQL Server 2008 se introduce una nueva edición:&#160; SQL Server 2008 Web Edition, específicamente diseñada para entornos web de alta disponibilidad que se ejecutan sobre Windows Server. Ideal para disponer de aplicaciones web con costes reducidos y ofrecer soluciones de hosting para los clientes.</p>
<p>Para más información: <a href="http://www.microsoft.com/sqlserver/2008/en/us/editions.aspx">http://www.microsoft.com/sqlserver/2008/en/us/editions.aspx</a> </p>
</p>
<p> <span style="font-size:12pt;line-height:115%;font-family:&#39;"><font color="#000000"></font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2008/09/24/sqlserver-2008-disponible/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Profiling SQL CLR procedures con AQTime</title>
		<link>http://www.thedotnetway.net/2008/06/11/profiling-sql-clr-procedures-con-aqtime/</link>
		<comments>http://www.thedotnetway.net/2008/06/11/profiling-sql-clr-procedures-con-aqtime/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 13:56:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2008/06/11/profiling-sql-clr-procedures-con-aqtime/</guid>
		<description><![CDATA[Intentando mejorar el rendimiento de unos procedimientos almacenados CLR que utilizamos en un proyecto hemos dado con esta herramienta que nos ha facilitado mucho las cosas. Podéis descargaros una versión de prueba desde aquí. Y aquí tenéis los pasos necesarios para poder analizar procedimientos almacenados CLR.]]></description>
			<content:encoded><![CDATA[<p>Intentando mejorar el rendimiento de unos procedimientos almacenados CLR que utilizamos en un proyecto hemos dado con esta herramienta que nos ha facilitado mucho las cosas. Podéis descargaros una versión de prueba desde <a href="http://automatedqa.com/downloads/aqtime/index.asp" target="_blank">aquí</a>.</p>
<p><font color="#800080"><a href="http://automatedqa.com/products/aqtime/"><img alt="Aqtimebanner" src="http://www.thedotnetway.net/content/binary/aqtimebanner.gif" border="0" /></a></font></p>
<p>Y <a href="http://automatedqa.com/products/aqtime/index.asp" target="_blank">aquí</a> tenéis los pasos necesarios para poder analizar procedimientos almacenados CLR.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2008/06/11/profiling-sql-clr-procedures-con-aqtime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>M&#233;todos An&#243;nimos y SQLCLR</title>
		<link>http://www.thedotnetway.net/2007/11/20/metodos-anonimos-y-sqlclr/</link>
		<comments>http://www.thedotnetway.net/2007/11/20/metodos-anonimos-y-sqlclr/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 15:36:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2007/11/20/metodos-anonimos-y-sqlclr/</guid>
		<description><![CDATA[Estaba escribiendo unos procedimientos almacenados SQLCLR, usaba algunos delegados para filtrar Listas y al intentar implementar la dll en el Servidor SQL obtenía, aunque el compilador no se quejaba de nada al generar, este error: Error 2 Error de CREATE ASSEMBLY porque el tipo &#8216;StoredProcedures&#8217; del ensamblado safe &#8216;NameSpace.MyClase&#8217; tiene un campo estático &#8216;&#60;&#62;9__CachedAnonymousMethodDelegate1&#8242;. Los [...]]]></description>
			<content:encoded><![CDATA[<p>Estaba escribiendo unos procedimientos almacenados SQLCLR, usaba algunos delegados para filtrar Listas y al intentar implementar la dll en el Servidor SQL obtenía, aunque el compilador no se quejaba de nada al generar, este error:</p>
<p><em>Error 2 Error de CREATE ASSEMBLY porque el tipo &#8216;StoredProcedures&#8217; del ensamblado safe &#8216;NameSpace.MyClase&#8217; tiene un campo estático &#8216;&lt;&gt;9__CachedAnonymousMethodDelegate1&#8242;. Los atributos de campos estáticos de ensamblados safe deben estar marcados como readonly en Visual C#, ReadOnly en Visual Basic o initonly en Visual C++ y el lenguaje intermedio. NameSpace.MyClase</em></p>
<p>La solución es marcar la Clase con el Atributo [System.Runtime.CompilerServices.CompilerGenerated]</p>
</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:dc623cf3-afe7-4b8b-9de7-b104e8d6cc58" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;font-family:Microsoft Sans Serif;font-size:11px;"><span style="color:#000000;">[System.Runtime.CompilerServices.CompilerGenerated]
</span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">partial</span><span style="color:#000000;"> </span><span style="color:#0000FF;">class</span><span style="color:#000000;"> StoredProcedures
{
    [SqlProcedure]
    </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">static</span><span style="color:#000000;"> </span><span style="color:#0000FF;">void</span><span style="color:#000000;"> MyProcedure(SqlChars XmlRQ)
    {}
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>Si tienes la clase marcada con ese atributo ya puedes usar delegados.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2007/11/20/metodos-anonimos-y-sqlclr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft SQL Server 2008 CTP y Visual Studio 2005 Support for SQL Server 2008 CTP</title>
		<link>http://www.thedotnetway.net/2007/11/20/microsoft-sql-server-2008-ctp-y-visual-studio-2005-support/</link>
		<comments>http://www.thedotnetway.net/2007/11/20/microsoft-sql-server-2008-ctp-y-visual-studio-2005-support/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 15:32:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQLServer]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2007/11/20/microsoft-sql-server-2008-ctp-y-visual-studio-2005-support/</guid>
		<description><![CDATA[Con tanto revuelo con el VS 2008 y el framework 3.5 nos hemos olvidado de algunas cosas. Se ha liberado el CTP de Noviembre de SQL Server 2008 y además se ha liberado el CTP del soporte de SQL2008 en VS 2005]]></description>
			<content:encoded><![CDATA[<p>Con tanto revuelo con el VS 2008 y el framework 3.5 nos hemos olvidado de algunas cosas.</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e1109aef-1aa2-408d-aa0f-9df094f993bf&amp;displaylang=en"><img src="http://www.thedotnetway.net/content/binary/sqlserver2008box.jpg" border="0" /><img src="http://www.thedotnetway.net/content/binary/vs2005box.jpg" border="0" /></a></p>
<p>Se ha liberado el <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=3BF4C5CA-B905-4EBC-8901-1D4C1D1DA884&amp;displaylang=en">CTP de Noviembre de SQL Server 2008</a> y además se ha liberado el <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=3BF4C5CA-B905-4EBC-8901-1D4C1D1DA884&amp;displaylang=en">CTP del soporte de SQL2008 en VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2007/11/20/microsoft-sql-server-2008-ctp-y-visual-studio-2005-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Explicaci&#243;n visual de SQL Joins</title>
		<link>http://www.thedotnetway.net/2007/10/23/explicacion-visual-de-sql-joins/</link>
		<comments>http://www.thedotnetway.net/2007/10/23/explicacion-visual-de-sql-joins/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 09:27:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2007/10/23/explicacion-visual-de-sql-joins/</guid>
		<description><![CDATA[Un artículo en Coding Horror que me ha gustado mucho que explica de forma intuitiva y gráfica los joins en SQL. &#160;A Visual Explanation of SQL Joins]]></description>
			<content:encoded><![CDATA[<p>Un <a href="http://www.codinghorror.com/blog/archives/000976.html">artículo</a> en <a href="http://www.codinghorror.com">Coding Horror</a> que me ha gustado mucho que explica de forma intuitiva y gráfica los joins en SQL.</p>
<p><a href="http://www.codinghorror.com/blog/archives/000976.html"><img src="http://www.thedotnetway.net/content/binary/joins112.PNG" border="0" /></a></p>
<p>&#160;<a href="http://www.codinghorror.com/blog/archives/000976.html">A Visual Explanation of SQL Joins</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2007/10/23/explicacion-visual-de-sql-joins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Desencadenadores en SQL Server</title>
		<link>http://www.thedotnetway.net/2007/06/01/desencadenadores-en-sql-server/</link>
		<comments>http://www.thedotnetway.net/2007/06/01/desencadenadores-en-sql-server/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 10:10:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2007/06/01/desencadenadores-en-sql-server/</guid>
		<description><![CDATA[Podemos escribir desencadenadores para INSERT, UPDATE, DELETE y UPDATE OF. INSERT se dispara al insertar un nuevo registro UPDATE se dispara al modificar un registro DELETE se dispara al borrar un registro UPDATE OF se dispara al modificar una columna concreta de un registro El desencadenador puede ser para uno de los eventos o para [...]]]></description>
			<content:encoded><![CDATA[<p>Podemos escribir desencadenadores para INSERT, UPDATE, DELETE y UPDATE OF.</p>
<p>INSERT se dispara al insertar un nuevo registro    <br />UPDATE se dispara al modificar un registro     <br />DELETE se dispara al borrar un registro     <br />UPDATE OF se dispara al modificar una columna concreta de un registro</p>
<p>El desencadenador puede ser para uno de los eventos o para todos a la vez.</p>
<p>La manera de crear un nuevo trigger en el SQL es la siguiente:</p>
<p> <font color="#2b91af">
<p>CREATE TRIGGER [MiTrigger] ON [Tabla] &#8212;Nombre del trigger y a que tabla afectara      <br />FOR INSERT, UPDATE, DELETE&#160; &#8212;Los eventos en los que queremos que se dispare       <br />AS       <br />&#8212; Aquí&#160; ponemos el código</p>
<p> </font>
<p>Para que se dispare al actualizar una columna especifica</p>
<p> <font color="#2b91af">
<p>CREATE TRIGGER [MiTrigger] ON [Tabla]      <br />FOR UPDATE OF NombreDeColumna&#160; &#8212; La columna que tiene que ser modificada para que el evento se dispare       <br />AS       <br />&#8212; Aquí&#160; ponemos el código</p>
<p> </font>
<p>Desde los triggers tenemos acceso a dos tablas virtuales del SQL con las cuales podemos saber los valores del registro que&#160; <br />dispara el trigger, estas tablas son Inserted y Deleted.</p>
<p>Estas tablas funcionan de la siguiente manera.</p>
<p>INSERT: Tenemos los valores del registro en la tabla Inserted.    <br />UPDATE: Los valores antiguos los encontramos en Deleted, los nuevos en Inserted.     <br />DELETE: Tenemos los valores del registro en la tabla Deleted.</p>
<p>Para acceder a estos valores, lo podemos hacer de la siguiente manera, cambiando Inserted por Deleted según el trigger y    <br />el valor al que queramos acceder:</p>
<p> <font color="#2b91af">
<p>DECLARE @Id int      <br />SELECT @Id = (SELECT Id FROM Inserted) </p>
<p> </font>
<p>Podemos abortar transacciones desde los triggers, para eso disponemos de RollBack Tran, usándolo podemos abortar    <br />la transacción desde el trigger y lanzar un error al cliente con RAISE ERROR, además, igual que en los procedimientos,     <br />la variable @@error contendrá el numero, si lo hay, del ultimo error.</p>
<p> <font color="#2b91af">
<p>IF @@error &lt;&gt;&#160; 0 BEGIN      <br />RollBack Tran       <br />RAISE&#160; ERROR (Error ,16, 1)       <br />END</p>
<p> </font>
<p>Por último es importante saber que, al escribir el código en los desencadenadores no podemos usar las siguientes funciones:</p>
<p><font color="#2b91af"><font color="#999999"></font>      <br />ALTER DATABASE       <br />CREATE DATABASE       <br />DROP DATABASE       <br />LOAD DATABASE       <br />RESTORE DATABASE       <br />DISK INIT       <br />DISK RESIZE       <br />LOAD LOG       <br />RECONFIGURE LOG       <br />RESTORE LOG</font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2007/06/01/desencadenadores-en-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET, IIS, SQL Server 2005 y Cache de Datos</title>
		<link>http://www.thedotnetway.net/2007/05/27/aspnet-iis-sql-server-2005-y-cache-de-datos/</link>
		<comments>http://www.thedotnetway.net/2007/05/27/aspnet-iis-sql-server-2005-y-cache-de-datos/#comments</comments>
		<pubDate>Sun, 27 May 2007 10:11:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[SQLServer]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2007/05/27/aspnet-iis-sql-server-2005-y-cache-de-datos/</guid>
		<description><![CDATA[Para activar el cache de datos del SQL en el IIS, debemos ejecutar varios comandos en la consola, encontraremos el aspnet_regsql.exe en la carpeta del framework. Para registrar el servidor SQL: aspnet_regsql.exe -S &#34;NombreDelServidorSql&#34; -E -d &#34;NombreDeLaBaseDeDatos&#34; -ed Para cada una de las tablas que queramos cachear: aspnet_regsql.exe -S &#34;NombreDelServidorSql&#34; -E -d &#34;NombreDeLabaseDeDatos&#34; -et -t [...]]]></description>
			<content:encoded><![CDATA[<p>Para activar el cache de datos del SQL en el IIS, debemos ejecutar varios comandos en la consola, encontraremos el aspnet_regsql.exe en la carpeta del framework.</p>
<p>Para registrar el servidor SQL:</p>
<ul>
<li><font color="#2b91af" size="2">aspnet_regsql.exe -S &quot;NombreDelServidorSql&quot; -E -d &quot;NombreDeLaBaseDeDatos&quot; -ed</font> </li>
</ul>
<p>Para cada una de las tablas que queramos cachear:</p>
<ul>
<li><font color="#2b91af" size="2">aspnet_regsql.exe -S &quot;NombreDelServidorSql&quot; -E -d &quot;NombreDeLabaseDeDatos&quot; -et -t &quot;NombreDeLaTabla&quot;</font> </li>
</ul>
<p>Para poder usar el cache en nuestro servicio o aplicacion ASP.NET debemos añadir una seccion en el Web.config</p>
<p> <font color="#a31515" size="2">
<p>&lt;system.web&gt;      <br />&#160;&#160;&#160; &lt;caching&gt;       <br />&#160;&#160;&#160;&#160;&#160; &lt;sqlCacheDependency enabled=&quot;true&quot; pollTime=&quot;1000&quot; &gt;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;databases&gt;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;add name=&quot;AliasDeLaBaseDeDatos&quot; connectionStringName=&quot;ClaveDeLaConnecionString&quot; /&gt;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/databases&gt;       <br />&#160;&#160;&#160;&#160;&#160; &lt;/sqlCacheDependency&gt;       <br />&#160;&#160;&#160; &lt;/caching&gt;       <br />&lt;/system.web&gt; </p>
<p> </font>
<p>En esta sección definimos el pollTime que es el intervalo, en milisegundos ,en que debe ir a comprobar si las tablas han cambiado, los demas campos creo que estan claros.</p>
<p>Este tema del pollTime no esta muy claro, ya que, aunque la documentacion dice lo que os he puesto, con las pruebas que hice comprobe que el sistema trabaja por notificacion de cambios, osea que vacia el cache cuando detecta que han cambiado los datos &#8230;</p>
<p>Una vez configurado el IIS y el web.config de la Aplicación vamos al codigo.</p>
<p>Podemos crear dependencia del cache sobre una tabla con:</p>
<p> <font size="2">
</p>
<p>   <font color="#2b91af" size="2">SqlCacheDependency</font><font size="2"> cacheDepen = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">SqlCacheDependency</font><font size="2">(</font><font color="#a31515" size="2">&quot;AliasDeLaBaseDeDatos&quot;</font><font size="2">, </font><font color="#a31515" size="2">&quot;NombreDeLaTabla&quot;</font><font size="2">);</font> </font>
<p><font size="2">O podemos crear dependencia sobre varias tablas con:</font></p>
<p> <font size="2"><font size="2">
</p>
<p>     <font color="#2b91af" size="2">SqlCacheDependency</font><font size="2"> cacheDepen1 = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">SqlCacheDependency</font><font size="2">(</font><font color="#a31515" size="2">&quot;AliasDeLaBaseDeDatos&quot;</font><font size="2">, </font><font color="#a31515" size="2">&quot;NombreDeLaTabla1&quot;</font><font size="2">);</font> </font>
<p><font color="#2b91af" size="2">SqlCacheDependency</font><font size="2"> cacheDepen2 = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">SqlCacheDependency</font><font size="2">(</font><font color="#a31515" size="2">&quot;AliasDeLaBaseDeDatos&quot;</font><font size="2">, </font><font color="#a31515" size="2">&quot;NombreDeLaTabla2&quot;</font><font size="2">);</font></p>
</p>
<p>   <font color="#2b91af" size="2">AggregateCacheDependency</font><font size="2"> aggDep = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">AggregateCacheDependency</font><font size="2">(); </font>
<p>aggDep.Add(cacheDepen1, cacheDepen2);</p>
<p> </font>
<p>Ya que el objecto Cache soporta ambos al crear una entrada:</p>
<p> <font size="2">
<p>_miCache.Add(key, result, cacheDepen , </p>
<p> </font><font color="#2b91af" size="2">Cache</font><font size="2">.NoAbsoluteExpiration,</font><font color="#2b91af" size="2">Cache</font><font size="2">.NoSlidingExpiration, </font><font color="#2b91af" size="2">CacheItemPriority</font><font size="2">.Default, </font><font color="#0000ff" size="2">null</font><font size="2">);</font>
<p><font size="2">ó</font></p>
<p> <font size="2"><font size="2">
<p>_miCache.Add(key, result, aggDep, </p>
<p>   </font><font color="#2b91af" size="2">Cache</font><font size="2">.NoAbsoluteExpiration,</font><font color="#2b91af" size="2">Cache</font><font size="2">.NoSlidingExpiration, </font><font color="#2b91af" size="2">CacheItemPriority</font><font size="2">.Default, </font><font color="#0000ff" size="2">null</font><font size="2">);</font></font>
<p>Si lo que cacheais es el resultado de una sentencia SQL, no hay mayor complicacion, podemos usar como Clave (Key) la misma sentencia o su HashCode, pero si lo que cacheamos son resultados que como peticion tienen clases de parametros, ya es otro tema. </p>
<p>Con el segundo supuesto, para la clave del Cache (key) empeze utilizando el <font size="2">GetHashCode de la clase de peticion, pero me di cuenta de que no funciona para esto, para diferencias istancias de la misma clase de peticion con los mismos valores obtienes diferentes HashCode, asi que para la clave, en este caso, os recomiento utilizar el HashCode de la string del Xml que resulta de serializar la clase, esa fue la unica manera de que me funcionara bien.</font></p>
<p><font size="2">Para recuperar los datos del cache simplemente:</font></p>
<p> <font size="2"><font color="#0000ff" size="2">
<p>object</p>
<p>   </font><font size="2">cachedData = __miCache.Get(key);</font>
<p><font size="2">si el resultado es null, buscar los datos y meterlos en el Cache para la proxima vez <img src='http://www.thedotnetway.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </font></p>
<p> </font>
<p>Mas información sobre el tema en <a class="" href="http://msdn2.microsoft.com/es-es/library/dw21dchd(VS.80).aspx" target="_blank">MSDN</a> en la web del <a class="" href="http://www.elguille.info/colabora/puntoNET/jlopezi_CacheASPNET2.htm" target="_blank">Guille</a> o en <a class="" href="http://quickstarts.asp.net/QuickStartv20/aspnet/doc/caching/default.aspx" target="_blank">ASP.NET</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2007/05/27/aspnet-iis-sql-server-2005-y-cache-de-datos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
