понедельник, 24 октября 2016 г.

EF Data Annotations NEW

sp_executesql

exec sp_executesql N'UPDATE [dbo].[Students]
SET [StudentName] = @0
WHERE (([StudentId] = @1) AND ([StudentName] = @2))
',N'@0 nvarchar(max) ,@1 int,@2 nvarchar(max) ',@0=N'Steve',@1=1,@2=N'Bill'
go

exec sp_executesql
N'UPDATE [dbo].[Students]
SET [StudentName] = @0
WHERE (([StudentId] = @1) AND ([StudentName] = @2))',
N'@0 nvarchar(max) , @1 int, @2 nvarchar(max)  ',
 @0=N'Steve', @1=1, @2=N'Bill'
GO

EF Data Annotations NEW

EF Data Annotations NEW

EF DateTime to Date MS SQL Field

воскресенье, 2 октября 2016 г.

gitlab new

Git global setup

git config --global user.name ""
git config --global user.email ""

Create a new repository

git clone https://gitlab.com/groupe/gs.git
cd gs
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder or Git repository

cd existing_folder
git init
git remote add origin https://gitlab.com/groupe/gs.gitgit add .
git commit
git push -u origin master
2222222222222222

Git global setup

git config --global user.name ""
git config --global user.email ""

Create a new repository

git clone https://gitlab.com/user/gs.trade.git
cd gs.trade
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder or Git repository

cd existing_folder
git init
git remote add origin https://gitlab.com/user/gs.trade.git
git add .
git commit
git push -u origin master

четверг, 16 июня 2016 г.

Owin, Katana

AutoMap DataReader

AutoMapper

вторник, 12 января 2016 г.

Entityframework ConnectionString

Web.config and App.config

App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Users;Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="FortsTicks01" connectionString="Data Source=.\MSSQL12;Initial Catalog=FortsTicks01;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

Web.config:

<configuration>
  <configSections>    
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Users;Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="TimeSeries01" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=TimeSeries01;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

 <appSettings>

Dispose

вторник, 5 января 2016 г.

SQL, Data Types

SQL DateTime Types

FTP C#

BulkInsert EnetityFrameWork

суббота, 2 января 2016 г.

ArrayOfString to Byte Array

http://stackoverflow.com/questions/472906/converting-a-string-to-byte-array-without-using-an-encoding-byte-by-byte

http://stackoverflow.com/questions/14669820/how-to-convert-a-string-array-to-a-byte-array-java


Compress/Decompress

http://www.dotnetperls.com/compress

http://www.dotnetperls.com/decompress


 private byte[] Serialize(IEnumerable<Dto.Bar> bs)
        {
            BinaryFormatter bf = new BinaryFormatter();
            byte[] bytes;
            MemoryStream ms = new MemoryStream();

            var lst = bs.Select(b => b.ToStr()).ToList();

            bf.Serialize(ms, lst);
            ms.Seek(0, 0);
            
            var bts = ms.ToArray();

            return bts;
        }

 private IEnumerable<IBarSimple> DeSerialize(byte[] bytes)
        {
            BinaryFormatter bf = new BinaryFormatter();
            MemoryStream ms = new MemoryStream();
            ms.Write(bytes, 0, bytes.Length);
            ms.Seek(0, 0);

            var ss = (List<string>)bf.Deserialize(ms);
            var bs = ss.Select(s => s.ToBarDto()).ToList();
            return bs;

        }

 private byte[] Compress(byte[] bytes)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                using (GZipStream gzip = new GZipStream(ms, CompressionMode.Compress, true))
                {
                    gzip.Write(bytes, 0, bytes.Length);
                }
                return ms.ToArray();
            }

        }

 private byte[] DeCompress(byte[] bytes)
        {
            using (GZipStream gzstream = new GZipStream(new MemoryStream(bytes), CompressionMode.Decompress))
            {
                const int size = 4096;
                byte[] buffer = new byte[size];
                using (MemoryStream mstr = new MemoryStream())
                {
                    int count = 0;
                    do
                    {
                        count = gzstream.Read(buffer, 0, size);
                        if (count > 0)
                        {
                            mstr.Write(buffer, 0, count);
                        }
                    } while (count > 0);
                    return mstr.ToArray();
                }
            }

        }