Home c# error: not available due to security level, entity framework

error: not available due to security level, entity framework

Author

Date

Category

ShowOrders throws an error: ‘ShowOrders.ShowOrders (string)’ is inaccessible due to its protection level (CS0122) [Project_Geolab]

else if ("R" == command)
      {
        Console.WriteLine ("Enter Name");
        var email = Console.ReadLine ();
        new ShowOrders (email) .Show ();
      }
public class ShowOrders
{
  private readonly string email;
  ShowOrders (string email)
  {
    this.email = email;
  }
  public void Show ()
  {
    using (Technic context = new Technic ())
    {
      var findedRecords = context.Customers.Where (r = & gt; r.Email == this.email) .ToList ();
      if (findedRecords.Count () & gt; 0)
      {
        foreach (var item in findedRecords)
        {
          Console.WriteLine ($ "Id: {item.Id} Name: {item.Name} Age: {item.Age}");
        }
      }
    }
  }
}

Answer 1

Apparently you are creating a class from another assembly. By default (if no access modifier is specified) a class member will have the scope internal .

Make it public .

public class ShowOrders
{
  private readonly string email;
  public ShowOrders (string email)
  {
    this.email = email;
  }
... ... ...

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions