Class DataManager
The DataManager is a data management component used for performing data operations in applications. It acts as an abstraction for using local data source - IEnumerable and remote data source - web services returning JSON or oData.
Namespace: Syncfusion.Blazor
Assembly: Syncfusion.Blazor.dll
Syntax
public class DataManager : OwningComponentBase
Constructors
DataManager()
Declaration
public DataManager()
Properties
Accept
Specifies the accept type.
Declaration
public bool Accept { get; set; }
Property Value
Type |
---|
System.Boolean |
Adaptor
Gets or sets the data adaptor to be used by SfDataManager component.
- BlazorAdaptorDefault. BlazorAdaptor is used to process Enumerable data. It contains methods to process the given collection based on the queries.
- ODataAdaptor OData Adaptor provies ability to consume and manipulate data from OData services.
- ODataV4Adaptor ODatav4 Adaptor provies ability to consume and manipulate data from OData v4 services
- WebApiAdaptor WebApi Adaptor provies ability to consume and manipulate data from WebApi services. This adaptor is targeted to interact with Web API created using OData endpoint, it is extended from ODataAdaptor
- UrlAdaptor URL Adaptor is used when you are required to interact with all kind of remote services to retrieve data.
- RemoteSaveAdaptor Remote Save Adaptor is used for binding JSON data. It interacts with remote services only for CRUD operations.
- CustomAdaptor CustomAdaptor specifies that own data query and manipulation logic has been provided using custom adaptor component extended from DataAdaptor class.
- JsonAdaptor JsonAdaptor is used to process JSON data at the client side. It contains methods to process the given JSON data based on the queries.
- GraphQLAdaptor GraphQLAdaptor provides ability to consume and manipulate data from GraphQL services.
- GraphQLAdaptor GraphQLAdaptor provides ability to consume and manipulate data from GraphQL service.
Declaration
public Adaptors Adaptor { get; set; }
Property Value
Type |
---|
Adaptors |
AdaptorInstance
Specifies the custom adaptor class type. DataManager uses this type value to instantiate custom adaptor class.
Declaration
public Type AdaptorInstance { get; set; }
Property Value
Type |
---|
System.Type |
Remarks
DataManager uses Activator.CreateInstance method to create custom adaptor instance. Injecting services into custom adaptor class, is not supported while using this approach. To inject and use services, provide custom adaptor as a Blazor component by extending DataAdaptor class.
BaseUri
Gets the Base URL.
Declaration
public string BaseUri { get; set; }
Property Value
Type |
---|
System.String |
Remarks
BaseUri will be used to get absolute of Url, InsertUrl, UpdateUrl and RemoveUrl properties.
BatchUrl
Specifies the batch url.
Declaration
public string BatchUrl { get; set; }
Property Value
Type |
---|
System.String |
Remarks
Applicable for remote adaptors. When SaveChanges method is called, request will be made to BatchUrl. If BatchUrl is not provided, Url is used as fallback.
CachingPageSize
Specifies the caching page size.
Declaration
public int CachingPageSize { get; set; }
Property Value
Type |
---|
System.Int32 |
CrossDomain
When true, then indicates that the request is a cross-domain request.
Declaration
public bool CrossDomain { get; set; }
Property Value
Type |
---|
System.Boolean |
CrudUrl
Specifies the CRUD URL.
Declaration
public string CrudUrl { get; set; }
Property Value
Type |
---|
System.String |
Remarks
Applicable for remote adaptors. When Insert, Remove or Update method is called, request will be made to CrudUrl. If CrudUrl is not provided, Url is used as fallback.
DataType
Specifies the data type.
Declaration
public string DataType { get; set; }
Property Value
Type |
---|
System.String |
EnableCaching
Enables data caching.
Declaration
public bool EnableCaching { get; set; }
Property Value
Type |
---|
System.Boolean |
GraphQLAdaptorOptions
Gets or Sets the properties to be specified for GraphQLAdaptor.
Declaration
public GraphQLAdaptorOptions GraphQLAdaptorOptions { get; set; }
Property Value
Type |
---|
GraphQLAdaptorOptions |
Headers
Specifies the key/value pair of headers.
Declaration
public IDictionary<string, string> Headers { get; set; }
Property Value
Type |
---|
System.Collections.Generic.IDictionary<System.String, System.String> |
Remarks
Use Headers to add any custom headers to the request made by DataManager. Users can also send authentication bearer token using Headers property.
HttpClientInstance
Specifies the HttpClient instance to be used by DataManager.
Declaration
public HttpClient HttpClientInstance { get; set; }
Property Value
Type |
---|
System.Net.Http.HttpClient |
Remarks
Use HttpClientInstance property to inject named HttpClient into DataManager.
InsertUrl
Specifies the insert URL.
Declaration
public string InsertUrl { get; set; }
Property Value
Type |
---|
System.String |
Remarks
Applicable for remote adaptors. When Insert method is called, request will be made to InsertUrl. If InsertUrl is not provided, Url is used as fallback.
Json
Specifies the IEnumerable collection. This data could be queried and manipulated.
Declaration
public IEnumerable<object> Json { get; set; }
Property Value
Type |
---|
System.Collections.Generic.IEnumerable<System.Object> |
Jsonp
Specifies the jsonp request.
Declaration
public string Jsonp { get; set; }
Property Value
Type |
---|
System.String |
jsRuntime
Declaration
protected IJSRuntime jsRuntime { get; set; }
Property Value
Type |
---|
Microsoft.JSInterop.IJSRuntime |
Key
Specifies the primary key value.
Declaration
public string Key { get; set; }
Property Value
Type |
---|
System.String |
Offline
Enables offline mode in datamanager.
Declaration
public bool Offline { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Applicable for remote data source. If offline is true then initial request will be made to fetch data. Further actions will be handled at the in-memory data and no more request will be made to the service. Cached data is stored in the JSON property.
RemoveUrl
Specifies the remove URL.
Declaration
public string RemoveUrl { get; set; }
Property Value
Type |
---|
System.String |
Remarks
Applicable for remote adaptors. When Remove method is called, request will be made to RemoveUrl. If RemoveUrl is not provided, Url is used as fallback.
RequiresFormat
Sepcifies requires format.
Declaration
public bool RequiresFormat { get; set; }
Property Value
Type |
---|
System.Boolean |
TimeTillExpiration
Specifies the time limit to clear the cached data.
Declaration
public int TimeTillExpiration { get; set; }
Property Value
Type |
---|
System.Int32 |
UpdateUrl
Specifies the update URL.
Declaration
public string UpdateUrl { get; set; }
Property Value
Type |
---|
System.String |
Remarks
Applicable for remote adaptors. When Update method is called, request will be made to UpdateUrl. If UpdateUrl is not provided, Url is used as fallback.
Url
Specifies the endpoint URL. DataManager requests this URL when data is needed.
Declaration
public string Url { get; set; }
Property Value
Type |
---|
System.String |
Methods
BeforeSend(HttpRequestMessage)
Invoked before sending http request.
Declaration
public void BeforeSend(HttpRequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpRequestMessage | request | HttpRequestMessage instance. |
Dispose()
Dispose unmanaged resources in the Syncfusion Blazor component.
Declaration
public virtual void Dispose()
Dispose(Boolean)
Dispose unmanaged resources in the Syncfusion Blazor component.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Boolean value to dispose the object. |
ExecuteQueryAsync<T>(Query)
Executes given query and returns resultant data.
Declaration
public Task<object> ExecuteQueryAsync<T>(Query query)
Parameters
Type | Name | Description |
---|---|---|
Query | query | Query class which will be executed against data source. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | Task. |
Type Parameters
Name | Description |
---|---|
T | Type of the model class. |
ExecuteQueryAsync<T>(DataManagerRequest)
Executes given query and returns resultant data.
Declaration
public Task<object> ExecuteQueryAsync<T>(DataManagerRequest queries)
Parameters
Type | Name | Description |
---|---|---|
DataManagerRequest | queries | Query class which will be executed against data source. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | Task |
Type Parameters
Name | Description |
---|---|
T | Type of the model class |
InsertAsync<T>(Object, String, Query, Int32)
Performs the new item add operation.
Declaration
public Task<object> InsertAsync<T>(object data, string tableName = null, Query query = null, int position = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Object | data | New item to be added. |
System.String | tableName | Table name to insert new item. |
Query | query | Query class instance. |
System.Int32 | position | Position to insert the new item. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | Task. |
Type Parameters
Name |
---|
T |
OnInitializedAsync()
Declaration
protected override Task OnInitializedAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
RemoveAsync<T>(String, Object, String, Query)
Performs the remove operation.
Declaration
public Task<object> RemoveAsync<T>(string keyField, object value, string tableName = null, Query query = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyField | Specifies the primary key. |
System.Object | value | Specifies the primary key field value. |
System.String | tableName | Table name of the update item. |
Query | query | Query instance. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | object. |
Type Parameters
Name |
---|
T |
SaveChangesAsync<T>(Object, Object, Object, String, Nullable<Int32>, String, Query, Object)
Performs the batch update operation. Enables user to perform add, update and remove items from data source in a single request.
Declaration
public Task<object> SaveChangesAsync<T>(object changed, object added, object deleted, string keyField, Nullable<int> dropIndex, string tableName = null, Query query = null, object Original = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | changed | Specifies the changed records. |
System.Object | added | Specifies the added records. |
System.Object | deleted | Specifies the deleted records. |
System.String | keyField | Specifies the primary key field. |
System.Nullable<System.Int32> | dropIndex | Specifies the record position, from which new records will be added. |
System.String | tableName | Table name of the update item. |
Query | query | Query class instance. |
System.Object | Original | Specifies the original data. Uses this original data for sending change items alone to the server. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | object. |
Type Parameters
Name |
---|
T |
UpdateAsync<T>(String, Object, String, Query, Object, IDictionary<String, Object>)
Performs the update operation.
Declaration
public Task<object> UpdateAsync<T>(string keyField, object data, string tableName = null, Query query = null, object original = null, IDictionary<string, object> updateProperties = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyField | Specifies the primary key. |
System.Object | data | Specifies the updated record. |
System.String | tableName | Table name of the update item. |
Query | query | Query instance. |
System.Object | original | Specifies the original data. Uses this original data for sending changed items alone to the server. |
System.Collections.Generic.IDictionary<System.String, System.Object> | updateProperties | Specifies the field names to be updated. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | object. |
Type Parameters
Name |
---|
T |