Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to get connection from startup to static class Data access?

$
0
0

I work on asp.net core 2.2 vs2017 app I face issue I cannot get connection string from start up to static Data access class 

class CZConnection
  public class CZConnection
    {


        public string DashboardConnection { get; set; }

    
    }
StartUp.cs
services.Configure<CZConnection>(DBConnection =>
            {
                DBConnection.DashboardConnection = Configuration.GetConnectionString("DashBoardSQLConnection");



            });

public static partial class DataAccess
{
  static SqlConnection InitializeConnection()
    {
     
          
               
                return new SqlConnection(here I need to get connection string of DBConnection.DashboardConnection);
             


        }
        return new SqlConnection();

 
}


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>