本文整理汇总了C#中EntitySpaces.Interfaces.esDataRequest类的典型用法代码示例。如果您正苦于以下问题:C# esDataRequest类的具体用法?C# esDataRequest怎么用?C# esDataRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
esDataRequest类属于EntitySpaces.Interfaces命名空间,在下文中一共展示了esDataRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetFromStatement
protected static string GetFromStatement(esDataRequest request, esDynamicQuerySerializable query, VistaDBCommand cmd, ref int pindex)
{
IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal;
string sql = String.Empty;
if (iQuery.InternalFromQuery == null)
{
sql = Shared.CreateFullName(query);
if (iQuery.JoinAlias != " ")
{
sql += " " + iQuery.JoinAlias;
}
}
else
{
IDynamicQuerySerializableInternal iSubQuery = iQuery.InternalFromQuery as IDynamicQuerySerializableInternal;
iSubQuery.IsInSubQuery = true;
sql += "(";
sql += BuildQuery(request, iQuery.InternalFromQuery, cmd, ref pindex);
sql += ")";
if (iSubQuery.SubQueryAlias != " ")
{
sql += " AS " + iSubQuery.SubQueryAlias;
}
iSubQuery.IsInSubQuery = false;
}
return sql;
}
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:35,代码来源:QueryBuilder.cs
示例2: esSaveDataTable
/// <summary>
/// Used to issue a Save command on an esEntity or esEntityCollection.
/// </summary>
/// <param name="request">Contains all of the information necessary to issue and carry out the request</param>
/// <param name="sig">Contains the required information to locate the EntitySpaces DataProvider</param>
/// <returns></returns>
public esDataResponse esSaveDataTable(esDataRequest request, esProviderSignature sig)
{
request.DatabaseVersion = sig.DatabaseVersion;
esDataResponse response = esProviderFactory.GetDataProvider(sig.DataProviderName, sig.DataProviderClass).esSaveDataTable(request);
// NOTE: New to 1.6.0. We do not rethrow the exception here, we do rethrow it in
// esEntityCollection.SaveToProviderInsertsUpdates after we assign the errors to the proper rows.
return response;
}
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:16,代码来源:esDataProvider.cs
示例3: PrepareCommand
public static VistaDBCommand PrepareCommand(esDataRequest request)
{
esDynamicQuerySerializable query = request.DynamicQuery;
VistaDBCommand cmd = new VistaDBCommand();
int pindex = NextParamIndex(cmd);
string sql = BuildQuery(request, query, cmd, ref pindex);
cmd.CommandText = sql;
return cmd;
}
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:12,代码来源:QueryBuilder.cs
示例4: esLoadDataTable
/// <summary>
/// Used to populate an esEntity or esEntityCollection with data.
/// </summary>
/// <param name="request">Contains all of the information necessary to issue and carry out the request</param>
/// <param name="sig">Contains the required information to locate the EntitySpaces DataProvider</param>
/// <returns></returns>
public esDataResponse esLoadDataTable(esDataRequest request, esProviderSignature sig)
{
request.DatabaseVersion = sig.DatabaseVersion;
esDataResponse response = esProviderFactory.GetDataProvider(sig.DataProviderName, sig.DataProviderClass).esLoadDataTable(request);
if(request.DynamicQuery != null)
{
request.DynamicQuery.es.LastQuery = response.LastQuery;
}
if (response.IsException)
{
throw response.Exception;
}
return response;
}
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:22,代码来源:esDataProvider.cs
示例5: ExecuteNonQuery
/// <summary>
/// Used to execute a non-data return query through the EntitySpaces DataProvider
/// </summary>
/// <param name="request">Contains all of the information necessary to issue and carry out the request</param>
/// <param name="sig">Contains the required information to locate the EntitySpaces DataProvider</param>
/// <returns></returns>
public esDataResponse ExecuteNonQuery(esDataRequest request, esProviderSignature sig)
{
request.DatabaseVersion = sig.DatabaseVersion;
esDataResponse response = esProviderFactory.GetDataProvider(sig.DataProviderName, sig.DataProviderClass).ExecuteNonQuery(request);
if (response.IsException)
{
throw response.Exception;
}
if (response.Parameters != null && response.Parameters.Count > 0)
{
request.Parameters.Merge(response.Parameters);
}
return response;
}
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:23,代码来源:esDataProvider.cs
示例6: BuildQuery
protected static string BuildQuery(esDataRequest request, esDynamicQuerySerializable query, VistaDBCommand cmd, ref int pindex)
{
IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal;
string select = GetSelectStatement(request, query, cmd, ref pindex);
string from = GetFromStatement(request, query, cmd, ref pindex);
string join = GetJoinStatement(request, query, cmd, ref pindex);
string where = GetComparisonStatement(request, query, iQuery.InternalWhereItems, " WHERE ", cmd, ref pindex);
string groupBy = GetGroupByStatement(request, query, cmd, ref pindex);
string having = GetComparisonStatement(request, query, iQuery.InternalHavingItems, " HAVING ", cmd, ref pindex);
string orderBy = GetOrderByStatement(request, query, cmd, ref pindex);
string setOperation = GetSetOperationStatement(request, query, cmd, ref pindex);
string sql = String.Empty;
sql += "SELECT " + select + " FROM " + from + join + where + setOperation + groupBy + having + orderBy;
return sql;
}
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:19,代码来源:QueryBuilder.cs
示例7: esTraceArguments
public esTraceArguments(esDataRequest request, IDbCommand cmd, string action, string callStack)
{
PacketOrder = Interlocked.Increment(ref esTraceArguments.packetOrder);
this.command = cmd;
TraceChannel = DataProvider.sTraceChannel;
Syntax = "ORACLE";
Request = request;
ThreadId = Thread.CurrentThread.ManagedThreadId;
Action = action;
CallStack = callStack;
SqlCommand = cmd;
ApplicationName = System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);
IDataParameterCollection parameters = cmd.Parameters;
if (parameters.Count > 0)
{
Parameters = new List<ITraceParameter>(parameters.Count);
for (int i = 0; i < parameters.Count; i++)
{
OracleParameter param = parameters[i] as OracleParameter;
esTraceParameter p = new esTraceParameter()
{
Name = param.ParameterName,
Direction = param.Direction.ToString(),
ParamType = param.OracleType.ToString().ToUpper(),
BeforeValue = param.Value != null ? Convert.ToString(param.Value) : "null"
};
this.Parameters.Add(p);
}
}
stopwatch = Stopwatch.StartNew();
}
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:39,代码来源:DataProvider.cs
示例8: esDataResponse
esDataResponse IDataProvider.ExecuteReader(esDataRequest request)
{
esDataResponse response = new esDataResponse();
SACommand cmd = null;
try
{
cmd = new SACommand();
if (request.CommandTimeout != null) cmd.CommandTimeout = request.CommandTimeout.Value;
if (request.Parameters != null) Shared.AddParameters(cmd, request);
switch (request.QueryType)
{
case esQueryType.TableDirect:
cmd.CommandType = CommandType.TableDirect;
cmd.CommandText = request.QueryText;
break;
case esQueryType.StoredProcedure:
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = Shared.CreateFullName(request);
break;
case esQueryType.Text:
cmd.CommandType = CommandType.Text;
cmd.CommandText = request.QueryText;
break;
case esQueryType.DynamicQuery:
cmd = QueryBuilder.PrepareCommand(request);
break;
}
cmd.Connection = new SAConnection(request.ConnectionString);
cmd.Connection.Open();
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "ExecuteReader", System.Environment.StackTrace))
{
try
{
response.DataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion Profiling
{
response.DataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
}
catch (Exception ex)
{
CleanupCommand(cmd);
response.Exception = ex;
}
return response;
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:69,代码来源:DataProvider.cs
示例9: esTraceArguments
public esTraceArguments(esDataRequest request, IDbCommand cmd, esEntitySavePacket packet, string action, string callStack)
{
PacketOrder = Interlocked.Increment(ref esTraceArguments.packetOrder);
this.command = cmd;
TraceChannel = DataProvider.sTraceChannel;
Syntax = "SYBASE";
Request = request;
ThreadId = Thread.CurrentThread.ManagedThreadId;
Action = action;
CallStack = callStack;
SqlCommand = cmd;
ApplicationName = System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);
IDataParameterCollection parameters = cmd.Parameters;
if (parameters.Count > 0)
{
Parameters = new List<ITraceParameter>(parameters.Count);
for (int i = 0; i < parameters.Count; i++)
{
SAParameter param = parameters[i] as SAParameter;
esTraceParameter p = new esTraceParameter()
{
Name = param.ParameterName,
Direction = param.Direction.ToString(),
ParamType = param.SADbType.ToString().ToUpper(),
BeforeValue = param.Value != null && param.Value != DBNull.Value ? Convert.ToString(param.Value) : "null"
};
try
{
// Let's make it look like we're using parameters for the profiler
if (param.Value == null || param.Value == DBNull.Value)
{
if (param.SourceVersion == DataRowVersion.Current)
{
object o = packet.CurrentValues[param.SourceColumn];
if (o != null && o != DBNull.Value)
{
p.BeforeValue = Convert.ToString(o);
}
}
else if (param.SourceVersion == DataRowVersion.Original)
{
object o = packet.OriginalValues[param.SourceColumn];
if (o != null && o != DBNull.Value)
{
p.BeforeValue = Convert.ToString(o);
}
}
}
}
catch { }
this.Parameters.Add(p);
}
}
stopwatch = Stopwatch.StartNew();
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:64,代码来源:DataProvider.cs
示例10: SetOriginalValues
private static void SetOriginalValues(esDataRequest request, esEntitySavePacket packet, DataRow row, bool primaryKeysAndConcurrencyOnly)
{
foreach (esColumnMetadata col in request.Columns)
{
if (primaryKeysAndConcurrencyOnly &&
(!col.IsInPrimaryKey && !col.IsConcurrency && !col.IsEntitySpacesConcurrency)) continue;
string columnName = col.Name;
if (packet.OriginalValues.ContainsKey(columnName))
{
row[columnName] = packet.OriginalValues[columnName];
}
}
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:15,代码来源:DataProvider.cs
示例11: SetModifiedValues
private static void SetModifiedValues(esDataRequest request, esEntitySavePacket packet, DataRow row)
{
foreach (string column in packet.ModifiedColumns)
{
if (request.Columns.FindByColumnName(column) != null)
{
row[column] = packet.CurrentValues[column];
}
}
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:10,代码来源:DataProvider.cs
示例12: LoadDataSetFromStoredProcedure
static private esDataResponse LoadDataSetFromStoredProcedure(esDataRequest request)
{
esDataResponse response = new esDataResponse();
SqlCeCommand cmd = null;
try
{
DataSet dataSet = new DataSet();
cmd = new SqlCeCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = Shared.CreateFullName(request);
if (request.CommandTimeout != null) cmd.CommandTimeout = request.CommandTimeout.Value;
if (request.Parameters != null) Shared.AddParameters(cmd, request);
SqlCeDataAdapter da = new SqlCeDataAdapter();
da.SelectCommand = cmd;
try
{
esTransactionScope.Enlist(da.SelectCommand, request.ConnectionString, CreateIDbConnectionDelegate);
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "LoadFromStoredProcedure", System.Environment.StackTrace))
{
try
{
da.Fill(dataSet);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion
{
da.Fill(dataSet);
}
}
finally
{
esTransactionScope.DeEnlist(da.SelectCommand);
}
response.DataSet = dataSet;
if (request.Parameters != null)
{
Shared.GatherReturnParameters(cmd, request, response);
}
}
catch (Exception ex)
{
CleanupCommand(cmd);
throw ex;
}
finally
{
}
return response;
}
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:69,代码来源:DataProvider.cs
示例13: LoadDataTableFromText
private static esDataResponse LoadDataTableFromText(esDataRequest request)
{
esDataResponse response = new esDataResponse();
SACommand cmd = null;
try
{
DataTable dataTable = new DataTable(request.ProviderMetadata.Destination);
cmd = new SACommand();
cmd.CommandType = CommandType.Text;
if (request.CommandTimeout != null) cmd.CommandTimeout = request.CommandTimeout.Value;
if (request.Parameters != null) Shared.AddParameters(cmd, request);
SADataAdapter da = new SADataAdapter();
cmd.CommandText = request.QueryText;
da.SelectCommand = cmd;
try
{
esTransactionScope.Enlist(da.SelectCommand, request.ConnectionString, CreateIDbConnectionDelegate);
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "LoadFromText", System.Environment.StackTrace))
{
try
{
da.Fill(dataTable);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion Profiling
{
da.Fill(dataTable);
}
}
finally
{
esTransactionScope.DeEnlist(da.SelectCommand);
}
response.Table = dataTable;
if (request.Parameters != null)
{
Shared.GatherReturnParameters(cmd, request, response);
}
}
catch (Exception)
{
CleanupCommand(cmd);
throw;
}
finally
{
}
return response;
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:70,代码来源:DataProvider.cs
示例14: CreateDataTable
private static DataTable CreateDataTable(esDataRequest request)
{
DataTable dataTable = new DataTable();
DataColumnCollection dataColumns = dataTable.Columns;
esColumnMetadataCollection cols = request.Columns;
if (request.SelectedColumns == null)
{
esColumnMetadata col;
for (int i = 0; i < cols.Count; i++)
{
col = cols[i];
dataColumns.Add(new DataColumn(col.Name, col.Type));
}
}
else
{
foreach (string col in request.SelectedColumns.Keys)
{
dataColumns.Add(new DataColumn(col, cols[col].Type));
}
}
return dataTable;
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:25,代码来源:DataProvider.cs
示例15: SaveDynamicEntity
private static DataTable SaveDynamicEntity(esDataRequest request)
{
bool needToDelete = request.EntitySavePacket.RowState == esDataRowState.Deleted;
DataTable dataTable = CreateDataTable(request);
using (SADataAdapter da = new SADataAdapter())
{
da.AcceptChangesDuringUpdate = false;
DataRow row = dataTable.NewRow();
dataTable.Rows.Add(row);
SACommand cmd = null;
switch (request.EntitySavePacket.RowState)
{
case esDataRowState.Added:
cmd = da.InsertCommand = Shared.BuildDynamicInsertCommand(request, request.EntitySavePacket.ModifiedColumns);
SetModifiedValues(request, request.EntitySavePacket, row);
break;
case esDataRowState.Modified:
cmd = da.UpdateCommand = Shared.BuildDynamicUpdateCommand(request, request.EntitySavePacket.ModifiedColumns);
SetOriginalValues(request, request.EntitySavePacket, row, false);
SetModifiedValues(request, request.EntitySavePacket, row);
row.AcceptChanges();
row.SetModified();
break;
case esDataRowState.Deleted:
cmd = da.DeleteCommand = Shared.BuildDynamicDeleteCommand(request, request.EntitySavePacket);
SetOriginalValues(request, request.EntitySavePacket, row, true);
row.AcceptChanges();
row.Delete();
break;
}
if (!needToDelete && request.Properties != null)
{
request.Properties["esDataRequest"] = request;
request.Properties["esEntityData"] = request.EntitySavePacket;
dataTable.ExtendedProperties["props"] = request.Properties;
}
DataRow[] singleRow = new DataRow[1];
singleRow[0] = row;
try
{
if (!request.IgnoreComputedColumns)
{
da.RowUpdated += new SARowUpdatedEventHandler(OnRowUpdated);
}
esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, request.EntitySavePacket, "SaveEntityDynamic", System.Environment.StackTrace))
{
try
{
da.Update(singleRow);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion Profiling
{
da.Update(singleRow);
}
}
finally
{
esTransactionScope.DeEnlist(cmd);
}
}
return dataTable;
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:90,代码来源:DataProvider.cs
示例16: SaveDynamicCollection
private static DataTable SaveDynamicCollection(esDataRequest request)
{
esEntitySavePacket pkt = request.CollectionSavePacket[0];
if (pkt.RowState == esDataRowState.Deleted)
{
//============================================================================
// We do all our deletes at once, so if the first one is a delete they all are
//============================================================================
return SaveDynamicCollection_Deletes(request);
}
else
{
//============================================================================
// We do all our Inserts and Updates at once
//============================================================================
return SaveDynamicCollection_InsertsUpdates(request);
}
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:19,代码来源:DataProvider.cs
示例17: SaveDynamicCollection_Deletes
private static DataTable SaveDynamicCollection_Deletes(esDataRequest request)
{
SACommand cmd = null;
DataTable dataTable = CreateDataTable(request);
using (esTransactionScope scope = new esTransactionScope())
{
using (SADataAdapter da = new SADataAdapter())
{
da.AcceptChangesDuringUpdate = false;
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
try
{
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
cmd = da.DeleteCommand = Shared.BuildDynamicDeleteCommand(request, request.CollectionSavePacket[0]);
esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);
DataRow[] singleRow = new DataRow[1];
// Delete each record
foreach (esEntitySavePacket packet in request.CollectionSavePacket)
{
DataRow row = dataTable.NewRow();
dataTable.Rows.Add(row);
SetOriginalValues(request, packet, row, true);
row.AcceptChanges();
row.Delete();
singleRow[0] = row;
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, packet, "SaveCollectionDynamic", System.Environment.StackTrace))
{
try
{
da.Update(singleRow);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion Profiling
{
da.Update(singleRow);
}
if (row.HasErrors)
{
request.FireOnError(packet, row.RowError);
}
dataTable.Rows.Clear(); // ADO.NET won't let us reuse the same DataRow
}
}
finally
{
esTransactionScope.DeEnlist(cmd);
}
}
scope.Complete();
}
return request.Table;
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:77,代码来源:DataProvider.cs
示例18: LoadManyToMany
private static esDataResponse LoadManyToMany(esDataRequest request)
{
esDataResponse response = new esDataResponse();
SACommand cmd = null;
try
{
DataTable dataTable = new DataTable(request.ProviderMetadata.Destination);
cmd = new SACommand();
cmd.CommandType = CommandType.Text;
if (request.CommandTimeout != null) cmd.CommandTimeout = request.CommandTimeout.Value;
string mmQuery = request.QueryText;
string[] sections = mmQuery.Split('|');
string[] tables = sections[0].Split(',');
string[] columns = sections[1].Split(',');
string prefix = String.Empty;
if (request.Catalog != null || request.ProviderMetadata.Catalog != null)
{
prefix += Delimiters.TableOpen;
prefix += request.Catalog != null ? request.Catalog : request.ProviderMetadata.Catalog;
prefix += Delimiters.TableClose + ".";
}
if (request.Schema != null || request.ProviderMetadata.Schema != null)
{
prefix += Delimiters.TableOpen;
prefix += request.Schema != null ? request.Schema : request.ProviderMetadata.Schema;
prefix += Delimiters.TableClose + ".";
}
string table0 = prefix + Delimiters.TableOpen + tables[0] + Delimiters.TableClose;
string table1 = prefix + Delimiters.TableOpen + tables[1] + Delimiters.TableClose;
string sql = "SELECT * FROM " + table0 + " JOIN " + table1 + " ON " + table0 + ".[" + columns[0] + "] = ";
sql += table1 + ".[" + columns[1] + "] WHERE " + table1 + ".[" + sections[2] + "] = ?";
if (request.Parameters != null)
{
Shared.AddParameters(cmd, request);
}
SADataAdapter da = new SADataAdapter();
cmd.CommandText = sql;
da.SelectCommand = cmd;
try
{
esTransactionScope.Enlist(da.SelectCommand, request.ConnectionString, CreateIDbConnectionDelegate);
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "LoadManyToMany", System.Environment.StackTrace))
{
try
{
da.Fill(dataTable);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion Profiling
{
da.Fill(dataTable);
}
}
finally
{
esTransactionScope.DeEnlist(da.SelectCommand);
}
response.Table = dataTable;
}
catch (Exception)
{
CleanupCommand(cmd);
throw;
}
finally
{
}
return response;
}
开发者ID:jssgarcia,项目名称:ESLite,代码行数:98,代码来源:DataProvider.cs
示例19: LoadManyToMany
static private esDataResponse LoadManyToMany(esDataRequest request)
{
esDataResponse response = new esDataResponse();
SqlCeCommand cmd = null;
try
{
DataTable dataTable = new DataTable(request.ProviderMetadata.Destination);
cmd = new SqlCeCommand();
cmd.CommandType = CommandType.Text;
if (request.CommandTimeout != null) cmd.CommandTimeout = request.CommandTimeout.Value;
string mmQuery = request.QueryText;
string[] sections = mmQuery.Split('|');
string[] tables = sections[0].Split(',');
string[] columns = sections[1].Split(',');
// We build the query, we don't use Delimiters to avoid tons of extra concatentation
string sql = "SELECT * FROM [" + tables[0];
sql += "] JOIN [" + tables[1] + "] ON [" + tables[0] + "].[" + columns[0] + "] = [";
sql += tables[1] + "].[" + columns[1];
sql += "] WHERE [" + tables[1] + "].[" + sections[2] + "] = @";
if (request.Parameters != null)
{
foreach (esParameter esParam in request.Parameters)
{
sql += esParam.Name;
}
Shared.AddParameters(cmd, request);
}
SqlCeDataAdapter da = new SqlCeDataAdapter();
cmd.CommandText = sql;
da.SelectCommand = cmd;
try
{
esTransactionScope.Enlist(da.SelectCommand, request.ConnectionString, CreateIDbConnectionDelegate);
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "LoadManyToMany", System.Environment.StackTrace))
{
try
{
da.Fill(dataTable);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion
{
da.Fill(dataTable);
}
}
finally
{
esTransactionScope.DeEnlist(da.SelectCommand);
}
response.Table = dataTable;
}
catch (Exception ex)
{
CleanupCommand(cmd);
throw ex;
}
finally
{
}
return response;
}
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:85,代码来源:DataProvider.cs
示例20: SaveStoredProcCollection
private static DataTable SaveStoredProcCollection(esDataRequest request)
{
bool needToInsert = false;
bool needToUpdate = false;
bool needToDelete = false;
Dictionary<DataRow, esEntitySavePacket> rowMapping = null;
if (request.ContinueUpdateOnError)
{
rowMapping = new Dictionary<DataRow, esEntitySavePacket>();
}
//================================================
// Create the DataTable ...
//================================================
DataTable dataTable = CreateDataTable(request);
foreach (esEntitySavePacket packet in request.CollectionSavePacket)
{
DataRow row = dataTable.NewRow();
switch (request.EntitySavePacket.RowState)
{
case esDataRowState.Added:
SetModifiedValues(request, packet, row);
dataTable.Rows.Add(row);
if (request.ContinueUpdateOnError) rowMapping[row] = packet;
break;
case esDataRowState.Modified:
SetOriginalValues(request, packet, row, false);
SetModifiedValues(request, packet, row);
dataTable.Rows.Add(row);
row.AcceptChanges();
row.SetModified();
if (request.ContinueUpdateOnError) rowMapping[row] = packet;
break;
case esDataRowState.Deleted:
SetOriginalValues(request, packet, row, true);
dataTable.Rows.Add(row);
row.AcceptChanges();
row.Delete();
if (request.ContinueUpdateOnError) rowMapping[row] = packet;
break;
}
}
if (Shared.HasUpdates(dataTable.Rows, out needToInsert, out needToUpdate, out needToDelete))
{
using (SADataAdapter da = new SADataAdapter())
{
da.AcceptChangesDuringUpdate = false;
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
SACommand cmd = null;
if (needToInsert) da.InsertCommand = cmd = Shared.BuildStoredProcInsertCommand(request);
if (needToUpdate) da.UpdateCommand = cmd = Shared.BuildStoredProc
|
请发表评论