protected void GuardOrgCommand(ICrmOperation orgCommand) { if (orgCommand == null) { throw new ArgumentNullException("orgCommand"); } }
public override int ExecuteNonQuery() { Debug.WriteLine("CrmDbCommand.ExecuteNonQuery()", "CrmDbCommand"); EnsureHasCommandText(); EnsureOpenConnection(); // Generate the IOrgCommand. ICrmOperation orgCommand = ToOrgCommand(CommandBehavior.Default); // Execute the IOrgCommand and return the result. return(_CrmCommandExecutor.ExecuteNonQueryOperation(orgCommand)); }
protected virtual ICrmOperationResult Execute(ICrmOperation orgCommand) { ICrmOperationResult result = orgCommand.Execute(); if (result == null) { throw new NotSupportedException("Sorry, was not able to translate the command into the appropriate CRM SDK Organization Request message."); } return(result); }
public int ExecuteNonQueryOperation(ICrmOperation command) { // You can use ExecuteNonQuery to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables), or to change the data in a database by executing UPDATE, INSERT, or DELETE statements. // Although ExecuteNonQuery does not return any rows, any output parameters or return values mapped to parameters are populated with data. // For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. GuardOrgCommand(command); ICrmOperationResult result = command.Execute(); if (result == null) { throw new NotSupportedException("Sorry, was not able to translate the command into the appropriate CRM SDK Organization Request message."); } return result.ReturnValue; }
public override object ExecuteScalar() { Debug.WriteLine("CrmDbCommand.ExecuteScalar()", "CrmDbCommand"); EnsureHasCommandText(); EnsureOpenConnection(); // If the first column of the first row in the result set is not found, a null reference is returned. // If the value in the database is null, the query returns DBNull.Value. // Generate the IOrgCommand. ICrmOperation orgCommand = ToOrgCommand(CommandBehavior.Default); // Execute the IOrgCommand and get the results. var results = _CrmCommandExecutor.ExecuteOperation(orgCommand); // var results = _CrmCommandExecutor.ExecuteCommand(this, CommandBehavior.Default); return(results.ResultSet.GetScalar()); }
protected virtual void SetOperation(ICrmOperation operation) { if (CrmOperation == null) { CrmOperation = operation; return; } else if (!IsBatchOperation) { throw new InvalidOperationException("A BatchOperation is required when translating multiple operations ."); } var batchOperation = (BatchOperation)CrmOperation; batchOperation.AddOperation(operation); }
public int ExecuteNonQueryOperation(ICrmOperation command) { // You can use ExecuteNonQuery to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables), or to change the data in a database by executing UPDATE, INSERT, or DELETE statements. // Although ExecuteNonQuery does not return any rows, any output parameters or return values mapped to parameters are populated with data. // For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. GuardOrgCommand(command); ICrmOperationResult result = command.Execute(); if (result == null) { throw new NotSupportedException("Sorry, was not able to translate the command into the appropriate CRM SDK Organization Request message."); } return(result.ReturnValue); }
public void AddOperation(ICrmOperation operation) { int count = Operations.Count; Operations.Add(operation); int startPosition = count; if (count > 0) { var last = Operations[count - 1]; var multipPartOp = last as IMultipartOperation; if (multipPartOp != null) { startPosition = last.BatchRequestIndex + multipPartOp.RequestCount; } else { startPosition = last.BatchRequestIndex + 1; } } if (operation.IsBatchRequest) { // Combine the ExecuteMultipleRequests by moving the requests out of it into the batch. var execMultipleRequest = (ExecuteMultipleRequest)operation.Request; if (execMultipleRequest.Settings != null && execMultipleRequest.Settings.ContinueOnError) { throw new NotSupportedException("Cannot combine ExecuteMultipleRequest's with different ContinueOnError settings."); } foreach (var item in execMultipleRequest.Requests) { BatchRequest.Requests.Add(item); } } else { BatchRequest.Requests.Add(operation.Request); } operation.BatchRequestIndex = startPosition; operation.BatchOperation = this; operation.DbCommand = this.DbCommand; operation.CommandBehavior = this.CommandBehavior; }
public ICrmOperationResult ExecuteOperation(ICrmOperation command) { GuardOrgCommand(command); ICrmOperationResult result = null; // if ((behavior & CommandBehavior.KeyInfo) > 0) switch (command.DbCommand.CommandType) { case CommandType.Text: case CommandType.TableDirect: result = Execute(command); break; case CommandType.StoredProcedure: result = ExecuteStoredProcedureOperation(command); break; } return result; }
public ICrmOperationResult ExecuteOperation(ICrmOperation command) { GuardOrgCommand(command); ICrmOperationResult result = null; // if ((behavior & CommandBehavior.KeyInfo) > 0) switch (command.DbCommand.CommandType) { case CommandType.Text: case CommandType.TableDirect: result = Execute(command); break; case CommandType.StoredProcedure: result = ExecuteStoredProcedureOperation(command); break; } return(result); }
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { EnsureHasCommandText(); EnsureOpenConnection(); // Generate the IOrgCommand. ICrmOperation orgCommand = ToOrgCommand(behavior); // Execute the IOrgCommand and get the results. var results = _CrmCommandExecutor.ExecuteOperation(orgCommand); DbDataReader reader; if (behavior == CommandBehavior.CloseConnection) { reader = results.GetReader(_DbConnection); } else { reader = results.GetReader(); } return(reader); }
public ICrmOperation GetOperation(CrmDbCommand command, CommandBehavior behavior) { bool schemaOnly = (behavior & CommandBehavior.SchemaOnly) > 0; ICrmOperation result = null; switch (command.CommandType) { case CommandType.StoredProcedure: throw new System.NotImplementedException(); case CommandType.TableDirect: result = GetOperationFromTableDirectCommand(command, behavior); break; case CommandType.Text: result = GetOperationFromTextCommand(command, behavior); break; default: throw new System.NotImplementedException(); } return(result); }
protected virtual ICrmOperationResult ExecuteStoredProcedureOperation(ICrmOperation command) { // What would a stored procedure be in terms of Dynamics Crm SDK? // Perhaps this could be used for exectuign fetch xml commands...? throw new System.NotImplementedException(); }
protected virtual ICrmOperationResult Execute(ICrmOperation orgCommand) { ICrmOperationResult result = orgCommand.Execute(); if (result == null) { throw new NotSupportedException("Sorry, was not able to translate the command into the appropriate CRM SDK Organization Request message."); } return result; }