SQL Table to C# Class_Tabloyu Class'a çevirme

Blog Detay

SQL Table to C# Class_Tabloyu Class'a çevirme
SQL Table to C# Class_Tabloyu Class'a çevirme

SQL Table to C# Class_Tabloyu Class'a çevirme

<blockquote> <p>declare @TableName sysname = &#39;LG_003_03_STLINE&#39;<br /> declare @Result varchar(max) = &#39;public class &#39; + @TableName + &#39;<br /> {&#39;</p> <p>select @Result = @Result + &#39;<br /> &nbsp; &nbsp; public &#39; + ColumnType + NullableSign + &#39; &#39; + ColumnName + &#39; { get; set; }<br /> &#39;<br /> from<br /> (<br /> &nbsp; &nbsp; select&nbsp;<br /> &nbsp; &nbsp; &nbsp; &nbsp; replace(col.name, &#39; &#39;, &#39;_&#39;) ColumnName,<br /> &nbsp; &nbsp; &nbsp; &nbsp; column_id ColumnId,<br /> &nbsp; &nbsp; &nbsp; &nbsp; case typ.name&nbsp;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;bigint&#39; then &#39;long&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;binary&#39; then &#39;byte[]&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;bit&#39; then &#39;bool&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;char&#39; then &#39;string&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;date&#39; then &#39;DateTime&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;datetime&#39; then &#39;DateTime&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;datetime2&#39; then &#39;DateTime&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;datetimeoffset&#39; then &#39;DateTimeOffset&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;decimal&#39; then &#39;decimal&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;float&#39; then &#39;double&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;image&#39; then &#39;byte[]&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;int&#39; then &#39;int&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;money&#39; then &#39;decimal&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;nchar&#39; then &#39;string&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;ntext&#39; then &#39;string&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;numeric&#39; then &#39;decimal&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;nvarchar&#39; then &#39;string&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;real&#39; then &#39;float&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;smalldatetime&#39; then &#39;DateTime&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;smallint&#39; then &#39;short&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;smallmoney&#39; then &#39;decimal&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;text&#39; then &#39;string&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;time&#39; then &#39;TimeSpan&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;timestamp&#39; then &#39;long&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;tinyint&#39; then &#39;byte&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;uniqueidentifier&#39; then &#39;Guid&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;varbinary&#39; then &#39;byte[]&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when &#39;varchar&#39; then &#39;string&#39;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &#39;UNKNOWN_&#39; + typ.name<br /> &nbsp; &nbsp; &nbsp; &nbsp; end ColumnType,<br /> &nbsp; &nbsp; &nbsp; &nbsp; case&nbsp;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when col.is_nullable = 1 and typ.name in (&#39;bigint&#39;, &#39;bit&#39;, &#39;date&#39;, &#39;datetime&#39;, &#39;datetime2&#39;, &#39;datetimeoffset&#39;, &#39;decimal&#39;, &#39;float&#39;, &#39;int&#39;, &#39;money&#39;, &#39;numeric&#39;, &#39;real&#39;, &#39;smalldatetime&#39;, &#39;smallint&#39;, &#39;smallmoney&#39;, &#39;time&#39;, &#39;tinyint&#39;, &#39;uniqueidentifier&#39;)&nbsp;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; then &#39;?&#39;&nbsp;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &#39;&#39;&nbsp;<br /> &nbsp; &nbsp; &nbsp; &nbsp; end NullableSign<br /> &nbsp; &nbsp; from sys.columns col<br /> &nbsp; &nbsp; &nbsp; &nbsp; join sys.types typ on<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; col.system_type_id = typ.system_type_id AND col.user_type_id = typ.user_type_id<br /> &nbsp; &nbsp; where object_id = object_id(@TableName)<br /> ) t<br /> order by ColumnId</p> <p>set @Result = @Result &nbsp;+ &#39;<br /> }&#39;</p> <p>print @Result</p> </blockquote>

Bunu paylaş
SQL Server Configuration Manager Yok
Muhtasar beyannamesi bdp kontrol aşamasında org.mozilla.javascript.JavaScriptException...
Yazar erydogan
1992 yılı İstanbul doğumluyum. "Beykent Üniversitesi/Bilgisayar Programcılığı" bölümü mezunuyum, 7 yılı aşkın süredir Logo firmasının üretmiş olduğu ERP ürünlerine teknik destek vermek üzere “Logo Erp Danışmanı/Sistem Uzmanı” olarak çalıştım. 2020 Şubat ayında yıllardır hayalini kurduğum "kendi işimi yapma" düşüncemi hayata geçirmek üzere DGN Yazılım firmasını kurdum. Ayrıca .Net C# (MVC) yazılım dilini kullanarak Web tabanlı/Mobil Uyumlu, Logo yazılım entegreli ya da tamamen bağımsız uygulamalar geliştiriyorum.

İlişkili Bloglar:

0 Yorum

Copyrights © 2020 All Rights Reserved by DGN Software.