﻿<?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>SQL ile Model Property Oluşturmak &#8211; SQL Server Eğitimleri</title>
	<atom:link href="https://sqlserveregitimleri.com/etiket/sql-ile-model-property-olusturmak/feed" rel="self" type="application/rss+xml" />
	<link>https://sqlserveregitimleri.com</link>
	<description>SQL Server ile ilgili her şey</description>
	<lastBuildDate>Fri, 18 Feb 2022 08:06:20 +0000</lastBuildDate>
	<language>tr</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>
	<item>
		<title>SQL Server’da SQL Sorgusu ile Model Property Oluşturmak</title>
		<link>https://sqlserveregitimleri.com/sql-serverda-sql-sorgusu-ile-model-property-olusturmak</link>
		
		<dc:creator><![CDATA[Yavuz Selim Kart]]></dc:creator>
		<pubDate>Wed, 18 Sep 2019 07:04:27 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL ile Model Property Oluşturmak]]></category>
		<category><![CDATA[SQL Server’da SQL Sorgusu ile Model Property Oluşturmak]]></category>
		<category><![CDATA[SQL ve Model Property]]></category>
		<guid isPermaLink="false">http://sqlserveregitimleri.com/?p=7617</guid>

					<description><![CDATA[Herkese merhaba, Bu yazıda SQL Server’da sql sorgusu ile model property yapısının nasıl oluşturulacağından bahsedeceğim. Konu ile ilgili örneği internet üzerinde gördüm. Aşağıda kodu görmektesiniz. DECLARE...]]></description>
										<content:encoded><![CDATA[<p>Herkese merhaba,</p>
<p>Bu yazıda SQL Server’da sql sorgusu ile model property yapısının nasıl oluşturulacağından bahsedeceğim.</p>
<p>Konu ile ilgili örneği internet üzerinde gördüm. Aşağıda kodu görmektesiniz.</p>
<pre class="line-numbers"><code class="language-sql">DECLARE @TableName VARCHAR(100) = 'Categories'; --Tablo adını burada yazacaksınız 

WITH model
AS (SELECT ORDINAL_POSITION,
           COLUMN_NAME,
           DATA_TYPE,
           IS_NULLABLE,
           TABLE_NAME,
           CASE
               WHEN DATA_TYPE = 'bigint' THEN
                   'long'
               WHEN DATA_TYPE = 'int' THEN
                   'int'
               WHEN DATA_TYPE = 'smallint' THEN
                   'short'
               WHEN DATA_TYPE = 'varchar' THEN
                   'string'
               WHEN DATA_TYPE = 'nvarchar' THEN
                   'string'
               WHEN DATA_TYPE = 'char' THEN
                   'string'
               WHEN DATA_TYPE = 'datetime' THEN
                   'DateTime'
               WHEN DATA_TYPE = 'decimal' THEN
                   'decimal'
               WHEN DATA_TYPE = 'bit' THEN
                   'bool'
               WHEN DATA_TYPE = 'decimal' THEN
                   'decimal'
               WHEN DATA_TYPE = 'tinyint' THEN
                   'byte'
               WHEN DATA_TYPE = 'image' THEN
                   'byte[]'
               WHEN DATA_TYPE = 'timestamp' THEN
                   'string'
               WHEN DATA_TYPE = 'varbinary' THEN
                   'string'
               WHEN DATA_TYPE = 'text' THEN
                   'string'
               WHEN DATA_TYPE = 'float' THEN
                   'float'
               WHEN DATA_TYPE = 'date' THEN
                   'DateTime'
               WHEN DATA_TYPE = 'xml' THEN
                   ' '
               WHEN DATA_TYPE = 'time' THEN
                   ' '
               WHEN DATA_TYPE = 'numeric' THEN
                   ' '
               WHEN DATA_TYPE = 'uniqueidentifier' THEN
                   ' '
               WHEN DATA_TYPE = 'numeric' THEN
                   ' '
               ELSE
                   ' '
           END AS DataType
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = @TableName)
SELECT 0 AS Column_Position,
       ' public class ' + @TableName AS VModel
UNION
SELECT 0,
       '{'
UNION
SELECT 1,
       '[Key]'
UNION
SELECT ORDINAL_POSITION,
       'public ' + DataType + CASE
                                  WHEN
                                  (
                                      IS_NULLABLE = 'Yes'
                                      AND DataType != 'string'
                                  ) THEN
                                      '? '
                                  ELSE
                                      ' '
                              END + COLUMN_NAME + '{ get; set; }'
FROM model
UNION
SELECT MAX(ORDINAL_POSITION) + 1,
       '}'
FROM model
ORDER BY Column_Position;</code></pre>
<p>Kodu çalıştırdığınız zaman aşağıdaki sonucu göreceksiniz.</p>
<p><img fetchpriority="high" decoding="async" class="alignnone wp-image-7619 size-full" src="https://sqlserveregitimleri.com/wp-content/uploads/2019/09/sql-serverda-sql-sorgusu-ile-model-property-olusturmak-1.jpg" alt="SQL Server’da SQL Sorgusu ile Model Property Oluşturmak" width="700" height="507" srcset="https://sqlserveregitimleri.com/wp-content/uploads/2019/09/sql-serverda-sql-sorgusu-ile-model-property-olusturmak-1.jpg 700w, https://sqlserveregitimleri.com/wp-content/uploads/2019/09/sql-serverda-sql-sorgusu-ile-model-property-olusturmak-1-315x228.jpg 315w, https://sqlserveregitimleri.com/wp-content/uploads/2019/09/sql-serverda-sql-sorgusu-ile-model-property-olusturmak-1-414x300.jpg 414w, https://sqlserveregitimleri.com/wp-content/uploads/2019/09/sql-serverda-sql-sorgusu-ile-model-property-olusturmak-1-186x135.jpg 186w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<p>Görüldüğü üzere property değerleri class yapısında oluşturulmuş oldu.</p>
<p>Herkese çalışma hayatında ve yaşamında başarılar kolaylıklar.</p>
<div class='epvc-post-count'><span class='epvc-eye'></span>  <span class="epvc-count"> 320</span><span class='epvc-label'> Kez Okundu</span></div>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
