• 大小: 34.11MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-10
  • 语言: C#
  • 标签: c#  

资源简介

Professional C# 7 and .NET Core 2.0.pdf 文档Professional C# 7 and .NET Core 2.0 demo

资源截图

代码片段和文件信息

using Microsoft.Extensions.Configuration;
using System;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Threading.Tasks;

namespace AsyncSamples
{
    class Program
    {
        static async Task Main()
        {
            await ReadAsync(“Wrox Press“);
        }

        public static async Task ReadAsync(string title)
        {
            var connection = new SqlConnection(GetConnectionString());

            string sql = “SELECT [title] [Publisher] [ReleaseDate] FROM [ProCSharp].[Books] WHERE lower([title]) LIKE @title ORDER BY [ReleaseDate]“;

            var command = new SqlCommand(sql connection);
            var titleParameter = new SqlParameter(“title“ SqlDbType.NVarChar 50);
            titleParameter.Value = title;
            command.Parameters.Add(titleParameter);

            await connection.OpenAsync();

            using (SqlDataReader reader = await command.ExecuteReaderAsync(CommandBehavior.CloseConnection))
            {
                while (await reader.ReadAsync())
                {
                    int id = reader.GetInt32(0);
                    string booktitle = reader.GetString(1);
                    string publisher = reader[2].ToString();
                    DateTime? releaseDate = reader.IsDBNull(3) ? (DateTime?)null : reader.GetDateTime(3);
                    Console.WriteLine($“{id5}. {booktitle-40} {publisher-15} {releaseDate:d}“);
                }
            }
        }

        public static string GetConnectionString()
        {
            var configurationBuilder = new ConfigurationBuilder()
                .SetbasePath(Directory.GetCurrentDirectory())
                .AddJsonFile(“config.json“);

            IConfiguration config = configurationBuilder.Build();
            return config[“Data:DefaultConnection:ConnectionString“];
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        324  2018-06-25 11:23  ProfessionalCSharp7\.git\config

     文件         73  2018-06-25 11:23  ProfessionalCSharp7\.git\description

     文件         23  2018-06-25 11:23  ProfessionalCSharp7\.git\HEAD

     文件        478  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\applypatch-msg.sample

     文件        896  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\commit-msg.sample

     文件       3327  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\fsmonitor-watchman.sample

     文件        189  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\post-update.sample

     文件        424  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\pre-applypatch.sample

     文件       1642  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\pre-commit.sample

     文件       1348  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\pre-push.sample

     文件       4898  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\pre-rebase.sample

     文件        544  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\pre-receive.sample

     文件       1492  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\prepare-commit-msg.sample

     文件       3610  2018-06-25 11:23  ProfessionalCSharp7\.git\hooks\update.sample

     文件     525988  2018-06-25 11:23  ProfessionalCSharp7\.git\index

     文件        240  2018-06-25 11:23  ProfessionalCSharp7\.git\info\exclude

     文件        226  2018-06-25 11:23  ProfessionalCSharp7\.git\logs\HEAD

     文件        226  2018-06-25 11:23  ProfessionalCSharp7\.git\logs\refs\heads\master

     文件        226  2018-06-25 11:23  ProfessionalCSharp7\.git\logs\refs\remotes\origin\HEAD

     文件     213200  2018-06-25 11:23  ProfessionalCSharp7\.git\objects\pack\pack-8a343915c8da91336542eddb118775f02f42540f.idx

     文件    4540537  2018-06-25 11:23  ProfessionalCSharp7\.git\objects\pack\pack-8a343915c8da91336542eddb118775f02f42540f.pack

     文件        398  2018-06-25 11:23  ProfessionalCSharp7\.git\packed-refs

     文件         41  2018-06-25 11:23  ProfessionalCSharp7\.git\refs\heads\master

     文件         32  2018-06-25 11:23  ProfessionalCSharp7\.git\refs\remotes\origin\HEAD

     文件       5120  2018-06-25 11:23  ProfessionalCSharp7\.gitignore

     文件       3167  2018-06-25 11:23  ProfessionalCSharp7\ADONET\ADONetSamples\ADONetSamples.sln

     文件        545  2018-06-25 11:23  ProfessionalCSharp7\ADONET\ADONetSamples\AsyncSamples\AsyncSamples.csproj

     文件        151  2018-06-25 11:23  ProfessionalCSharp7\ADONET\ADONetSamples\AsyncSamples\config.json

     文件       1924  2018-06-25 11:23  ProfessionalCSharp7\ADONET\ADONetSamples\AsyncSamples\Program.cs

     文件        465  2018-06-25 11:23  ProfessionalCSharp7\ADONET\ADONetSamples\CommandSamples\CommandSamples.csproj

............此处省略4750个文件信息

评论

共有 条评论