1

I have created a simple example with below code. In my test project UI layer(.Net Core) I have a dependency to Business Layer and my Business Layer Reference to Data Layer. My question is why UI can import Data Layer functionality without referencing to Data because I really don't want to import that !!

 public class Program
{
    public static void Main(string[] args)
    {
        Data.Class1 class1 = new Class1();
        class1.foo();//i have access to data layer !!

        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>();
}

my project structure

Theo
  • 57,719
  • 8
  • 24
  • 41
  • 1
    That's because your business layer has a reference to it and your classes are public. Its bad enough that you reference data layer directly from business layer. Try [this answer](https://stackoverflow.com/a/46709599/455493) – Tseng Oct 26 '18 at 19:22
  • Tanks, it's worked. – Meysam Hadeli Oct 26 '18 at 20:24

0 Answers0