본문 바로가기
IT/C#

[.Net 교육] Day6 오전

by dya0 2020. 7. 22.

3.1 -> 5.0 

 

 

db설정

@ razor 

 

using문 위치

using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using BlazorApp9.Data;

namespace BlazorApp9
{
    public class Program
    {
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("app");

            builder.Services.AddScoped(
                sp => new HttpClient 
                { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
            //서비스 등록으로 inject 사용 

            // builder.Services.AddTransient(sp => new PersonService());
            builder.Services.AddTransient(sp =>new SaramService());
            var host = builder.Build();
            var personService = host.Services.GetRequiredService<PersonService>();
            //instanace
            await personService.GetPeople(); // data 생성
            await host.RunAsync();
            await builder.Build().RunAsync();
        }
    }
}

 

무식하게 나와도 안나오는 것보단 낫지 안되는데 왜 자꾸 암튼이래

 

 

 

 

 

 

 

 

 

 

'IT > C#' 카테고리의 다른 글

[.Net교육] Day 6 설치과정  (0) 2020.07.22
[.NET 교육] Day5 오전  (0) 2020.07.21
[c# 교육]day4 2  (0) 2020.07.20
[C#] 상속  (0) 2020.07.10
[C#] C# 클래스 확장  (0) 2020.07.09