C# |
---|
public class DbRequest |
Deserialize | Deserializes the DbRequest message. |
#ctor | Initializes an object instance. |
#ctor | The Copy constructor. |
#ctor | Initializes an object instance with the supplied values. |
Clone | Clones the structure of the object. |
Serialize | Serializes the object and returns the serialized string. |
Serialize | Serialize the object to the specified file. |
AddMissingColumns | Indicates if the missing column should be added. |
ClientSql | Gets or sets the ClientSql value. |
Columns | The included table columns. |
DataConfigName | The data configuration name. |
DbAssignedColumns | The Database Assigned columns. |
Filters | The where clause filters. |
Joins | The table joins. |
KeyColumns | The key column values. |
OrderByNames | The OrderBy column names. |
PageSize | The number of records in the page. |
PageStartIndex | The page starting index. |
Parameters | Gets or sets the Parameters list reference. |
ProcedureName | Gets or sets the ProcedureName value. |
RequestTypeName | The request type. (R) |
SchemaName | The schema name. |
TableName | The table name. |
C# |
---|
using System; using System.Collections.Generic; using LJCNetCommon; using LJCDBMessage; using LJCDBServiceLib; // A Person Data Record class. public class Person { <span class='xmlComment'>/// <summary>Gets or sets the PersonId value.</summary></span> public Int32 PersonId { get; set; } <span class='xmlComment'>/// <summary>Gets or sets the Name value.</summary></span> public string Name { get; set; } } // A console program. internal class Program { private static void Main(string[] args) { // Create a Data Definition which is a collection of column definitions. // Column definitions are required to communicate with the database. // The collection initializer uses an available collection "Add" method. // public DbColumn Add(string name, string propertyName = null, string renameAs = null // , string dataTypeName = "String", string caption = null) string personIDColumnName = "Person_ID"; string personIDDataPropertyName = "PersonId"; DbColumns personDefinition = new DbColumns() { { personIDColumnName, personIDDataPropertyName, "Int32"}, { "Name" } // Defaults to "String" }; // Create a list of the columns to be retrieved. List<string> propertyNames = new List<string>() { "PersonId", "Name" }; // Create a key record to specify the record to be retrieved. var keyColumns = new DbColumns() { { "PersonId", 1} }; // Create the DbRequest object. string tableName = "Person"; DbRequest dbRequest = new DbRequest("Select", tableName) { DataConfigName = "PersonData", Columns = DbCommon.GetRequestColumns(personDefinition, propertyNames), KeyColumns = DbCommon.GetRequestKeyColumns(keyColumns, personDefinition) }; // Create the Request XML message. string request = dbRequest.Serialize(); // Create the Data Service object. DbService dbService = new DbService(); // Execute the Request and get the Result XML message. string result = dbService.Execute(request); // Create a Data Record object to receive the values. Person person = new Person(); // Populate the Data Record object with the result values. // Uses resultData as an object and processes with reflection. DbCommon.SetObjectValues(result, person); int id = person.PersonId; string name = person.Name; } } |