0

Having problem in displaying relational properties b/w two tables having one(company) to many(package_master) relationship

Action

public ViewResult Index()
    {

  var companies = db.companies.Include(c => c.aspnet_Users)
                     .Include(c=>c.package_master);
        return View(companies.ToList());
    }

EntitySet

public partial class company
{
    public company()
    {
        this.package_master = new HashSet<package_master>();
    }

    public int company_id { get; set; }
    public string name { get; set; }
    public string address { get; set; }
    public string phone { get; set; }
    public string fax { get; set; }
    public Nullable<System.Guid> sen_sup { get; set; }

    public virtual aspnet_Users aspnet_Users { get; set; }
    public virtual ICollection<package_master> package_master { get; set; }
}

When I type Model.aspnet_Users.property1 everything works fine(intellisense) but now I also want to diaplay properties from packege_master(no intellisense)(foreign key table=package_master having client_id as foreign key, public key table=company having company_id as primary key)

1 Answer 1

2

package_master is a collection. You cannot access member properties of package_master entities directly like: Model.package_master.XXX. You must iterate the collection to get access to entities.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.