本文整理汇总了C#中DataRowState类的典型用法代码示例。如果您正苦于以下问题:C# DataRowState类的具体用法?C# DataRowState怎么用?C# DataRowState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataRowState类属于命名空间,在下文中一共展示了DataRowState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Insert
public void Insert(DbConnection conn, string tableName, DataTable sourceData, Dictionary<string, string> columnMappings = null, DataRowState state = DataRowState.Added)
{
SqlConnection sqlConn = conn as SqlConnection;
Check(conn);
using (SqlBulkCopyWrapper sqlBC = new SqlBulkCopyWrapper(sqlConn))
{
sqlBC.BatchSize = 10000;
sqlBC.BulkCopyTimeout = 600;
sqlBC.DestinationTableName = tableName;
if (columnMappings != null && columnMappings.Count > 0)
{
foreach (var item in columnMappings)
{
sqlBC.ColumnMappings.Add(item.Value, item.Key);
}
}
else
{
foreach (var item in sourceData.Columns.Cast<DataColumn>())
{
sqlBC.ColumnMappings.Add(item.ColumnName, item.ColumnName);
}
}
sqlBC.WriteToServer(sourceData, state);
}
}
开发者ID:piaolingzxh,项目名称:Justin,代码行数:28,代码来源:BulkCopySQL.cs
示例2: IncidentBoxRow
public IncidentBoxRow()
{
_state = DataRowState.Added;
_IsDefault = false;
_ControllerId = -1;
_ManagerId = -1;
}
开发者ID:0anion0,项目名称:IBN,代码行数:7,代码来源:IncidentBoxRow.cs
示例3: VCardRow
public VCardRow()
{
_state = DataRowState.Added;
_Birthday = DateTime.MinValue;
_OrganizationId = -1;
}
开发者ID:0anion0,项目名称:IBN,代码行数:7,代码来源:VCardRow.cs
示例4: SynchronizationMetadataRow
public SynchronizationMetadataRow()
{
_state = DataRowState.Added;
_Uri = null;
_Timestamp = null;
}
开发者ID:0anion0,项目名称:IBN,代码行数:8,代码来源:SynchronizationMetadataRow1.cs
示例5: EMailRouterPop3BoxActivityRow
public EMailRouterPop3BoxActivityRow()
{
_state = DataRowState.Added;
_IsActive = false;
_TotalMessageCount = 0;
}
开发者ID:0anion0,项目名称:IBN,代码行数:8,代码来源:EMailRouterPop3BoxActivityRow.cs
示例6: ProjectSpreadSheetDataRow
public ProjectSpreadSheetDataRow()
{
_state = DataRowState.Added;
_Index = 0;
_CellType = 1;
}
开发者ID:0anion0,项目名称:IBN,代码行数:8,代码来源:ProjectSpreadSheetDataRow.cs
示例7: EMailMessageLogSettingsRow
public EMailMessageLogSettingsRow()
{
_state = DataRowState.Added;
_IsActive = false;
_Period = 7;
}
开发者ID:0anion0,项目名称:IBN,代码行数:8,代码来源:EMailMessageLogSettingsRow.cs
示例8: GeneratorCommand
/// <summary>
///
/// </summary>
/// <param name="connectionName"></param>
/// <param name="dbTableName"></param>
/// <param name="table"></param>
/// <returns></returns>
public static List<SqlCommandObject> GeneratorCommand(string connectionName, string dbTableName, DataTable table, DataRowState state)
{
if (connectionName.IsEmpty())
throw new Exception("GeneratorCommand方法中的connectionName为空.");
List<SqlCommandObject> cmds = new List<SqlCommandObject>();
if (table.IsEmpty())
return cmds;
InsertCommandGenerator insertCommandGenerator = new InsertCommandGenerator();
DeleteCommandGenerator deleteCommandGenerator = new DeleteCommandGenerator();
UpdateCommandGenerator updateCommandGenerator = new UpdateCommandGenerator();
SqlCommandObject cmd = null;
if (table != null)
{
DataTable dtChanges = null;
if (state == DataRowState.Unchanged)
{
dtChanges = table.GetChanges();
}
else
{
dtChanges = table.GetChanges(state);
}
if (dtChanges == null) return cmds;
if (dbTableName.IsEmpty())
throw new Exception("GeneratorCommand方法中的tableName为空.");
foreach (DataRow dr in dtChanges.Rows)
{
switch (dr.RowState)
{
case DataRowState.Deleted:
cmd = deleteCommandGenerator.GenerateCommand(connectionName, dbTableName, dr);
break;
case DataRowState.Modified:
cmd = updateCommandGenerator.GenerateCommand(connectionName, dbTableName, dr);
break;
case DataRowState.Added:
cmd = insertCommandGenerator.GenerateCommand(connectionName, dbTableName, dr);
break;
default:
cmd = null;
break;
}
if (cmd != null)
{
cmds.Add(cmd);
}
}
}
return cmds;
}
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:63,代码来源:SqlCommandObjectGenerator.cs
示例9: Entity
/// <summary>
/// Overloaded constructor.
/// </summary>
/// <param name="key">An <see cref="System.Object"/> that
/// represents the primary identifier value for the
/// class.</param>
protected Entity(Guid key)
{
_keyID = key;
if (_keyID == Guid.Empty)
{
_keyID = Entity.NewKey();
}
_state = DataRowState.Unchanged;
}
开发者ID:ramiroreal,项目名称:GestorFacturas,代码行数:16,代码来源:Entity.cs
示例10: mcweb_ReportAceRow
public mcweb_ReportAceRow()
{
_state = DataRowState.Added;
_Role = null;
_PrincipalId = null;
_Allow = false;
}
开发者ID:0anion0,项目名称:IBN,代码行数:10,代码来源:mcweb_ReportAceRow.cs
示例11: EMailRouterPop3BoxRow
public EMailRouterPop3BoxRow()
{
_state = DataRowState.Added;
_Port = 110;
_IsInternal = false;
_InternalEMailAddress = null;
_UseSecureConnection = 0;
}
开发者ID:0anion0,项目名称:IBN,代码行数:12,代码来源:EMailRouterPop3BoxRow.cs
示例12: SmtpBoxRow
public SmtpBoxRow()
{
_state = DataRowState.Added;
_Port = 25;
_SecureConnection = 0;
_Authenticate = false;
_IsDefault = false;
_Checked = false;
}
开发者ID:0anion0,项目名称:IBN,代码行数:14,代码来源:SmtpBoxRow.cs
示例13: SynchronizationReplicaRow
public SynchronizationReplicaRow()
{
_state = DataRowState.Added;
_PrincipalId = null;
_ReplicaKeyMap = null;
_CurrentKnowledge = null;
_ForgottenKnowledge = null;
_ConflictLog = null;
_TombstoneLog = null;
_LastDeletedItemsCleanupTime = null;
}
开发者ID:0anion0,项目名称:IBN,代码行数:18,代码来源:SynchronizationReplicaRow.cs
示例14: EnumRow
public bool EnumRow(DataRowState RowState)
{
if (OnRowEnumed != null)
{
foreach (DataRow row in dt.Rows)
{
OnRowEnumed(row);
}
if (dt != null && dt.Rows.Count > 0)
{
return true;
}
else
{
return false;
}
}
return false;
}
开发者ID:mind0n,项目名称:hive,代码行数:19,代码来源:TableEntity.cs
示例15: ucImageCollection
public ucImageCollection(StateCollection aIC)
{
pStatusBarText = string.Empty;
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
_pnl = new Panel();
_nav = new ucMoveNavigator();
_txt = new TextBox();
_nav.Location = new System.Drawing.Point(0, this.Height-_nav.Height);
_txt.Location = new System.Drawing.Point(_nav.Width+10, _nav.Top);
_txt.Width = Width - _txt.Left-10;
_txt.BackColor = SystemColors.Control;
_txt.TextAlign = HorizontalAlignment.Center;
_pnl.Location = new System.Drawing.Point(5, 5);
_pnl.Size = new System.Drawing.Size(this.Width-10, _nav.Top-10);
_pnl.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
_nav.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
_txt.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
Controls.AddRange(new Control [] {_pnl, _nav, _txt});
_pnl.Paint += new PaintEventHandler(_pnl_Paint);
_nav.MoveNavigator += new EvH_MoveNavigator(_nav_MoveNavigator);
_txt.TextChanged += new EventHandler(_txt_TextChanged);
_nav.pMinValue = 1;
pImageCollection = aIC;
_isFill = true;
_curImg = null;
_curState = DataRowState.Unchanged;
ResizeRedraw = true;
_tw = new Twain();
_tw.Init( this.Handle );
_msgfilter = false;
}
开发者ID:infobook,项目名称:Tools4,代码行数:42,代码来源:ucImageCollection.cs
示例16: createParam
/// <summary>
/// 根据数据表创建参数列表
/// </summary>
/// <param name="tab">数据表</param>
/// <returns>返回参数列表</returns>
public static NameObjectList[] createParam(DataTable tab, DataRowState state)
{
if (null == tab || tab.Rows.Count < 1)
return new NameObjectList[0];
List<NameObjectList> psList = new List<NameObjectList>();
DataView dvsub = new DataView(tab, "", "", DataViewRowState.ModifiedCurrent | DataViewRowState.Added | DataViewRowState.Deleted);
DataColumnCollection cols = tab.Columns;
int len = cols.Count;
for (int i = 0; i < dvsub.Count; i++)
{
if (state != dvsub[i].Row.RowState)
continue;
DataRowView drv = dvsub[i];
NameObjectList ps = new NameObjectList();
for (int c = 0; c < len; c++)
ps[cols[c].ColumnName] = drv[c];
psList.Add(ps);
}
return psList.ToArray();
}
开发者ID:thisisvoa,项目名称:GranityApp2.5,代码行数:25,代码来源:ParamManager.cs
示例17: GetChanges
public DataTable GetChanges(DataRowState rowStates)
{
IntPtr hscp;
Bid.ScopeEnter(out hscp, "<ds.DataTable.GetChanges|API> %d#, rowStates=%d{ds.DataRowState}\n", ObjectID, (int)rowStates);
try {
DataTable dtChanges = this.Clone();
DataRow row = null;
// check that rowStates is valid DataRowState
Debug.Assert(Enum.GetUnderlyingType(typeof(DataRowState)) == typeof(Int32), "Invalid DataRowState type");
for (int i = 0; i < Rows.Count; i++) {
row = Rows[i];
if ((row.RowState & rowStates) != 0)
dtChanges.ImportRow(row);
}
if (dtChanges.Rows.Count == 0)
return null;
return dtChanges;
}
finally {
Bid.ScopeLeave(ref hscp);
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:26,代码来源:DataTable.cs
示例18: WriteToServer
public void WriteToServer (DataTable table, DataRowState rowState)
{
BulkCopyToServer (table, rowState);
}
开发者ID:Profit0004,项目名称:mono,代码行数:4,代码来源:SqlBulkCopy.cs
示例19: BulkCopyToServer
private void BulkCopyToServer (DataTable table, DataRowState state)
{
if (connection == null || connection.State == ConnectionState.Closed)
throw new InvalidOperationException ("This method should not be called on a closed connection");
if (_destinationTableName == null)
throw new ArgumentNullException ("DestinationTableName");
if (isLocalConnection && connection.State != ConnectionState.Open)
connection.Open();
if ((copyOptions & SqlBulkCopyOptions.KeepIdentity) == SqlBulkCopyOptions.KeepIdentity) {
SqlCommand cmd = new SqlCommand ("set identity_insert " +
table.TableName + " on",
connection);
cmd.ExecuteScalar ();
}
DataTable [] columnMetaDataTables = GetColumnMetaData ();
DataTable colMetaData = columnMetaDataTables [0];
DataTable tableCollations = columnMetaDataTables [1];
if (_columnMappingCollection.Count > 0) {
if (_columnMappingCollection [0].SourceOrdinal != -1)
ordinalMapping = true;
ValidateColumnMapping (table, tableCollations);
}
SqlCommand tmpCmd = new SqlCommand ();
TdsBulkCopy blkCopy = new TdsBulkCopy ((Tds)connection.Tds);
if (((Tds)connection.Tds).TdsVersion >= TdsVersion.tds70) {
string statement = "insert bulk " + DestinationTableName + " (";
statement += GenerateColumnMetaData (tmpCmd, colMetaData, tableCollations);
statement += ")";
#region Check requested options and add corresponding modifiers to the statement
if ((copyOptions & insertModifiers) != SqlBulkCopyOptions.Default) {
statement += " WITH (";
bool commaRequired = false;
if ((copyOptions & SqlBulkCopyOptions.CheckConstraints) == SqlBulkCopyOptions.CheckConstraints) {
if (commaRequired)
statement += ", ";
statement += "CHECK_CONSTRAINTS";
commaRequired = true;
}
if ((copyOptions & SqlBulkCopyOptions.TableLock) == SqlBulkCopyOptions.TableLock) {
if (commaRequired)
statement += ", ";
statement += "TABLOCK";
commaRequired = true;
}
if ((copyOptions & SqlBulkCopyOptions.KeepNulls) == SqlBulkCopyOptions.KeepNulls) {
if (commaRequired)
statement += ", ";
statement += "KEEP_NULLS";
commaRequired = true;
}
if ((copyOptions & SqlBulkCopyOptions.FireTriggers) == SqlBulkCopyOptions.FireTriggers) {
if (commaRequired)
statement += ", ";
statement += "FIRE_TRIGGERS";
commaRequired = true;
}
statement += ")";
}
#endregion Check requested options and add corresponding modifiers to the statement
blkCopy.SendColumnMetaData (statement);
}
blkCopy.BulkCopyStart (tmpCmd.Parameters.MetaParameters);
long noRowsCopied = 0;
foreach (DataRow row in table.Rows) {
if (row.RowState == DataRowState.Deleted)
continue; // Don't copy the row that's in deleted state
if (state != 0 && row.RowState != state)
continue;
bool isNewRow = true;
int i = 0;
foreach (SqlParameter param in tmpCmd.Parameters) {
int size = 0;
object rowToCopy = null;
if (_columnMappingCollection.Count > 0) {
if (ordinalMapping) {
foreach (SqlBulkCopyColumnMapping mapping
in _columnMappingCollection) {
if (mapping.DestinationOrdinal == i && param.Value == null) {
rowToCopy = row [mapping.SourceOrdinal];
SqlParameter parameter = new SqlParameter (mapping.SourceOrdinal.ToString (),
rowToCopy);
if (param.MetaParameter.TypeName != parameter.MetaParameter.TypeName) {
parameter.SqlDbType = param.SqlDbType;
rowToCopy = parameter.Value = parameter.ConvertToFrameworkType (rowToCopy);
}
string colType = string.Format ("{0}", parameter.MetaParameter.TypeName);
if (colType == "nvarchar" || colType == "ntext" || colType == "nchar") {
if (row [i] != null && row [i] != DBNull.Value) {
size = ((string) parameter.Value).Length;
size <<= 1;
//.........这里部分代码省略.........
开发者ID:Profit0004,项目名称:mono,代码行数:101,代码来源:SqlBulkCopy.cs
示例20: OpenConnectionIfClosed
/// <summary>
/// Open connection if it was closed.
/// Necessary to workaround "connection must be open and valid" error
/// with batched updates.
/// </summary>
/// <param name="state">Row state</param>
/// <param name="openedConnections"> list of opened connections
/// If connection is opened by this function, the list is updated
/// </param>
/// <returns>true if connection was opened</returns>
private void OpenConnectionIfClosed(DataRowState state,
List<MySqlConnection> openedConnections)
{
MySqlCommand cmd = null;
switch (state)
{
case DataRowState.Added:
cmd = InsertCommand;
break;
case DataRowState.Deleted:
cmd = DeleteCommand;
break;
case DataRowState.Modified:
cmd = UpdateCommand;
break;
default:
return;
}
if (cmd != null && cmd.Connection != null &&
cmd.Connection.connectionState == ConnectionState.Closed)
{
cmd.Connection.Open();
openedConnections.Add(cmd.Connection);
}
}
开发者ID:rotmgkillroyx,项目名称:rotmg_svr_OLD,代码行数:36,代码来源:dataadapter.cs
注:本文中的DataRowState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论