Table<TEntity> Class

Definition

Represents a table for a particular type in the underlying database.

generic <typename TEntity>
 where TEntity : classpublic ref class Table sealed : System::Collections::Generic::IEnumerable<TEntity>, System::ComponentModel::IListSource, System::Data::Linq::ITable, System::Linq::IQueryable<TEntity>, System::Linq::IQueryProvider
public sealed class Table<TEntity> : System.Collections.Generic.IEnumerable<TEntity>, System.ComponentModel.IListSource, System.Data.Linq.ITable, System.Linq.IQueryable<TEntity>, System.Linq.IQueryProvider where TEntity : class
type Table<'Entity (requires 'Entity : null)> = class
    interface ITable
    interface IQueryProvider
    interface IListSource
    interface seq<'Entity (requires 'Entity : null)>
    interface IEnumerable
    interface IQueryable<'Entity (requires 'Entity : null)>
    interface IQueryable
Public NotInheritable Class Table(Of TEntity)
Implements IEnumerable(Of TEntity), IListSource, IQueryable(Of TEntity), IQueryProvider, ITable

Type Parameters

TEntity

The type of the data in the table.

Inheritance
Table<TEntity>
Implements

Remarks

This class enables you to query over the table and add, remove, and attach objects.

An application can access a Table<TEntity> instance via GetTable or by using a strongly typed property for the strongly typed DataContext. That is, when the designer generates a DataContext object, it generates properties to represent each Table. For example:

[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="SignOffTool")]  
public partial class DataClasses1DataContext : System.Data.Linq.DataContext {  
   public System.Data.Linq.Table<User> Users {  
      get {  
         return this.GetTable<User>();  
      }  
   }  
}  

For this strongly typed DataContext, you can access the Users property to get Table<User>.

Properties

Context

Gets the DataContext that has been used to retrieve this Table<TEntity>.

IsReadOnly

Gets a value that indicates whether the type of the entities contained in this Table<TEntity> instance has a primary key.

Methods

Attach(TEntity)

Attaches a disconnected or "detached" entity to a new DataContext when original values are required for optimistic concurrency checks.

Attach(TEntity, Boolean)

Attaches an entity to the DataContext in either a modified or unmodified state.

Attach(TEntity, TEntity)

Attaches an entity to the DataContext in either a modified or unmodified state by specifying both the entity and its original state.

AttachAll<TSubEntity>(IEnumerable<TSubEntity>)

Attaches all entities of a collection to the DataContext in either a modified or unmodified state.

AttachAll<TSubEntity>(IEnumerable<TSubEntity>, Boolean)

Attaches all entities of a collection to the DataContext in either a modified or unmodified state.

DeleteAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>)

Puts all entities from the collection into a pending delete state.

DeleteOnSubmit(TEntity)

Puts an entity from this table into a pending delete state.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator()

Gets an enumerator that iterates through the collection.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetModifiedMembers(TEntity)

Returns an array of modified members that contain their current and original values.

GetNewBindingList()

Creates a new list for binding to a data source.

GetOriginalEntityState(TEntity)

Returns a Table<TEntity> instance that contains the original state of the entity.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
InsertAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>)

Adds all entities of a collection to the DataContext in a pending insert state.

InsertOnSubmit(TEntity)

Adds an entity in a pending insert state to this Table<TEntity>.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the table.

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through the collection.

IEnumerable<TEntity>.GetEnumerator()

Returns an enumerator that iterates through the collection.

IListSource.ContainsListCollection

Gets a value that indicates whether the collection is a collection of IList objects.

IListSource.GetList()

Returns an IList that can be bound to a data source from an object that does not implement an IList itself.

IQueryable.ElementType

Gets the type of the element(s) that are returned when the expression tree associated with this object is executed.

IQueryable.Expression

Gets the expression tree that is associated with this instance of IQueryable.

IQueryable.Provider

Gets the query provider that is associated with this data source.

IQueryProvider.CreateQuery(Expression)

Constructs an IQueryable object that can evaluate the query represented by a specified expression tree.

IQueryProvider.CreateQuery<TResult>(Expression)

Constructs an IQueryable<T> object that can evaluate the query represented by a specified expression tree.

IQueryProvider.Execute(Expression)

Executes the query represented by a specified expression tree.

IQueryProvider.Execute<TResult>(Expression)

Executes the strongly-typed query represented by a specified expression tree.

ITable.Attach(Object)

Attaches an entity to the DataContext in an unmodified state.

ITable.Attach(Object, Boolean)

Attaches all entities of a collection to the DataContext in either a modified or unmodified state.

ITable.Attach(Object, Object)

Attaches an entity to the DataContext in either a modified or unmodified state by specifying both the entity and its original state.

ITable.AttachAll(IEnumerable)

Attaches all entities of a collection to the DataContext in either a modified or unmodified state.

ITable.AttachAll(IEnumerable, Boolean)

Attaches all entities of a collection to the DataContext in either a modified or unmodified state.

ITable.DeleteAllOnSubmit(IEnumerable)

Puts all entities from the collection into a pending delete state.

ITable.DeleteOnSubmit(Object)

Puts an entity from this table into a pending delete state.

ITable.GetModifiedMembers(Object)

Returns an array of modified members that contain their current and original values.

ITable.GetOriginalEntityState(Object)

Retrieves original values of a given entity.

ITable.InsertAllOnSubmit(IEnumerable)

Adds all entities of a collection to the DataContext in an pending insert state.

ITable.InsertOnSubmit(Object)

Adds an entity in a pending insert state to this table.

Extension Methods

CopyToDataTable<T>(IEnumerable<T>)

Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Cast<TResult>(IQueryable)

Converts the elements of an IQueryable to the specified type.

OfType<TResult>(IQueryable)

Filters the elements of an IQueryable based on a specified type.

SortBy<T>(IQueryable<T>, String)

Specifies a sort order.

Ancestors<T>(IEnumerable<T>)

Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the ancestors of every node in the source collection. Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

Returns a filtered collection of the child elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

Removes every node in the source collection from its parent node.

Applies to