<?xml version="1.0" encoding="utf-8"?>
<root>
  <!-- 
    Microsoft ResX Schema 
    
    Version 2.0
    
    The primary goals of this format is to allow a simple XML format 
    that is mostly human readable. The generation and parsing of the 
    various data types are done through the TypeConverter classes 
    associated with the data types.
    
    Example:
    
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
                
    There are any number of "resheader" rows that contain simple 
    name/value pairs.
    
    Each data row contains a name, and value. The row also contains a 
    type or mimetype. Type corresponds to a .NET class that support 
    text/value conversion through the TypeConverter architecture. 
    Classes that don't support this are serialized and stored with the 
    mimetype set.
    
    The mimetype is used for serialized objects, and tells the 
    ResXResourceReader how to depersist the object. This is currently not 
    extensible. For a given mimetype the value must be set accordingly:
    
    Note - application/x-microsoft.net.object.binary.base64 is the format 
    that the ResXResourceWriter will generate, however the reader can 
    read any of the formats listed below.
    
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array 
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="QueryCamporPorTablaRelacionados" xml:space="preserve">
    <value>select 
tab.name as Tabla,
col.name as Columna,
pk_tab.name as TablaPrincipal,
pk_col.name as ColumnaRelacion,
tp.name As TipoDato, 
case when ic.object_id is null then 0 else 1 end as PK
from sys.tables tab
    inner join sys.columns col 
        on col.object_id = tab.object_id
   inner join sys.types tp on col.system_type_id = tp.system_type_id
    left outer join sys.foreign_key_columns fk_cols
        on fk_cols.parent_object_id = tab.object_id
        and fk_cols.parent_column_id = col.column_id
    left outer join sys.foreign_keys fk
        on fk.object_id = fk_cols.constraint_object_id
    left outer join sys.tables pk_tab
        on pk_tab.object_id = fk_cols.referenced_object_id
    left outer join sys.columns pk_col
        on pk_col.column_id = fk_cols.referenced_column_id
        and pk_col.object_id = fk_cols.referenced_object_id
    left join sys.indexes i ON fk.object_id= i.object_id and i.is_primary_key = 1
	left join sys.index_columns ic ON col.column_id = ic.column_id and col.object_id = ic.object_id
where tab.name = '{0}'</value>
    <comment>Consulta que retorna los campos de las tablas con sus relaciones</comment>
  </data>
  <data name="QueryCamposPorTablas" xml:space="preserve">
    <value>select f.name AS FK_Nombre, f.object_id As FK_Id,OBJECT_NAME(f.referenced_object_id) As Tabla, c.name As Columna, tp.name As TipoDato, CASE WHEN c.is_nullable = 1 THEN 'YES' ELSE 'NO' END As Nullable from sys.foreign_keys f inner join sys.tables t on f.referenced_object_id = t.object_id inner join sys.columns c on c.object_id = t.object_id inner join sys.types tp on c.system_type_id = tp.system_type_id where f.object_id in ({0})
union
select '' AS FK_Nombre, 0 As FK_Id, OBJECT_NAME(t.object_id) As Tabla, c.name As Columna, tp.name As TipoDato, CASE WHEN c.is_nullable = 1 THEN 'YES' ELSE 'NO' END As Nullable from sys.tables t inner join sys.columns c on c.object_id = t.object_id inner join sys.types tp on c.system_type_id = tp.system_type_id where t.object_id in ({0})</value>
    <comment>Consulta que retorna campos de tablas seleccionadas para armar consulta LINQ</comment>
  </data>
  <data name="QueryColumnas" xml:space="preserve">
    <value>Select 
a.COLUMN_NAME,
a.DATA_TYPE,
a.IS_NULLABLE,
CASE WHEN b.CONSTRAINT_NAME like '%pk%' then 1 else 0 end AS 'IS_PK',
CASE WHEN b.CONSTRAINT_NAME like '%fk%' then 1 else 0 end AS 'IS_FK'
From INFORMATION_SCHEMA.columns as a 
LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE as b on a.table_name = b.table_name 
AND a.column_name = b.column_name 
where a.table_name = {0}</value>
    <comment>Consulta que retorna las columnas</comment>
  </data>
  <data name="QueryColumnasRelacion" xml:space="preserve">
    <value>SELECT f.name As FK_Nombre, f.object_id As FK_Id, OBJECT_NAME(fc.referenced_object_id) As TablaRelacion, COL_NAME(fc.parent_object_id, fc.parent_column_id) AS ColumnaOrigen, COL_NAME(fc.referenced_object_id, fc.referenced_column_id) As ColumnaRelacion FROM sys.foreign_keys f INNER JOIN sys.foreign_key_columns fc ON f.object_id = fc.constraint_object_id WHERE f.object_id in ({0}) ORDER BY 1</value>
    <comment>Consulta que retorna campos por los cuales se relaciona una tabla con otra.</comment>
  </data>
  <data name="QueryObtenerColumnas" xml:space="preserve">
    <value>Select a.COLUMN_NAME,a.DATA_TYPE,a.IS_NULLABLE,ISNULL(b.CONSTRAINT_NAME, '0') as 'IS_PK' From INFORMATION_SCHEMA.columns as a LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE as b on a.table_name = b.table_name AND a.column_name = b.column_name and b.constraint_name like'PK_%'  where a.table_name = @TableName</value>
  </data>
  <data name="QueryRelacionesTabla" xml:space="preserve">
    <value>SELECT DISTINCT f.name As FK_Nombre, f.object_id As FK_Id, OBJECT_NAME(fc.referenced_object_id) As TablaRelacion, STUFF((SELECT ',' + COL_NAME(fc.parent_object_id,fc.parent_column_id) FROM sys.foreign_key_columns fc WHERE fc.constraint_object_id = f.object_id FOR XML PATH('') ), 1, 1, '' ) As ColumnasRelacion FROM sys.foreign_keys f INNER JOIN sys.foreign_key_columns fc ON f.object_id = fc.constraint_object_id WHERE f.parent_object_id = OBJECT_ID('{0}')</value>
    <comment>Consulta que retorna relaciones de la tabla seleccionada.</comment>
  </data>
  <data name="QueryTablas" xml:space="preserve">
    <value> select 
	obj.object_id as table_id, 
	obj.name as table_name,
	SCHEMA_NAME(obj.schema_id) AS 'schema', 
	CASE WHEN Count(b.constraint_name) &gt; 0 THEN 'true' ELSE 'false' END AS fks
from sys.objects AS obj 
	left join information_schema.key_column_usage as b on obj.name = b.table_name AND b.CONSTRAINT_NAME LIKE '%fk%'
WHERE type = 'u'
GROUP BY
	obj.object_id,
	obj.name,
	obj.schema_id
order by table_name</value>
    <comment>Consulta que retorna las tablas y indica si tiene relaciones.</comment>
  </data>
</root>