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

Updating 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.

This topic demonstrates how to update artificial types. Basically, you need to use the SetFieldValue<T> extension method from the Telerik.OpenAccess namespace.

To use the FieldValue<T> and SetFieldValue<T> extension methods, you need to use/import the Telerik.OpenAccess namespace.

The following example demonstrates how to query a product artificial type and how to update it.

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

   product.SetFieldValue( "ProductName", "NewProductName" );
   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()

    ' Extension methods on objects should be called as static methods
    ' due to limitations in VB
    Telerik.OpenAccess.ExtensionMethods.SetFieldValue(product, "ProductName", "NewProductName")
    fluentContext.SaveChanges()
End Using

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