Ask a questionAsk a question
 

AnswerEntitySet<T>

  • Saturday, November 07, 2009 2:25 PMjunsy Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I can't find the EntitySet<T> in the programming environment,
    and I don't know how use it.
    Who can help me ?
    thanks.

Answers

  • Saturday, November 07, 2009 4:28 PMMartin Honnen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    EntitySet<T> is part of LINQ to SQL, it is in the namespace System.Data.Linq and in the assembly System.Data.Linq.dll.
    As for using it, normally you let Visual Studio generate a .NET represenation of your data base; that way you have classes representing the tables in your database where properties of type EntitySet<T> represent relationships between tables. Below is an example of a class Customer representing a table Customers; each Customer has a property Orders of type EntitySet<Order> representing a relationship between the Customers and the Orders table.

    [Table(Name = "Customers")]
    public partial class Customer
    {
        [Column(IsPrimaryKey = true)]
        public string CustomerID;
        // ...
        private EntitySet<Order> _Orders;
        [Association(Storage = "_Orders", OtherKey = "CustomerID")]
        public EntitySet<Order> Orders
        {
            get { return this._Orders; }
            set { this._Orders.Assign(value); }
        }
    }
    
    
    
    

    MVP XML My blog

All Replies

  • Saturday, November 07, 2009 4:28 PMMartin Honnen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    EntitySet<T> is part of LINQ to SQL, it is in the namespace System.Data.Linq and in the assembly System.Data.Linq.dll.
    As for using it, normally you let Visual Studio generate a .NET represenation of your data base; that way you have classes representing the tables in your database where properties of type EntitySet<T> represent relationships between tables. Below is an example of a class Customer representing a table Customers; each Customer has a property Orders of type EntitySet<Order> representing a relationship between the Customers and the Orders table.

    [Table(Name = "Customers")]
    public partial class Customer
    {
        [Column(IsPrimaryKey = true)]
        public string CustomerID;
        // ...
        private EntitySet<Order> _Orders;
        [Association(Storage = "_Orders", OtherKey = "CustomerID")]
        public EntitySet<Order> Orders
        {
            get { return this._Orders; }
            set { this._Orders.Assign(value); }
        }
    }
    
    
    
    

    MVP XML My blog