Data Access has been discontinued. Please refer to this page for more information.

Deleting Artificial Types

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

Deleting artificial types is the same as deleting regular CLR types. You need to pass the artificial type to the Delete method of the context and invoke SaveChanges. The following example demonstrates how to delete a product with id equals to 0.

using ( FluentModelContext fluentContext = new FluentModelContext() )
{
   object product = fluentContext
       .GetAll( "FluentModel.Product" )
       .Where( string.Format( "Id = {0}", 0 ) )
       .Cast<object>()
       .FirstOrDefault();

   fluentContext.Delete( product );
   fluentContext.SaveChanges();
}
Using fluentContext As New FluentModelContext()
    Dim product As Object = fluentContext.
        GetAll("FluentModel.Product").
        Where(String.Format("Id = {0}", 0)).
        Cast(Of Object)().
        FirstOrDefault()

    fluentContext.Delete(product)
    fluentContext.SaveChanges()
End Using

The How to: Bulk Delete Artificial Types article demonstrates how to delete large amounts of data on the server side.