internal void LoadValue(MDataCell cell) { StringValue = cell.StringValue; CellValue.Value = cell.Value; CellValue.State = cell.State; CellValue.IsNull = cell.IsNull; }
private void SetState(int state, BreakOp op, MDataCell cell) { switch (op) { case BreakOp.Null: if (cell.IsNull) { return; } break; case BreakOp.Empty: if (cell.StringValue == "") { return; } break; case BreakOp.NullOrEmpty: if (cell.IsNullOrEmpty) { return; } break; } cell.State = state; }
internal void LoadValue(MDataCell cell, bool isWithState) { isNewValue = true; CellValue.LoadValue(cell.CellValue, isWithState); if (isWithState) { isAllowChangeState = false; } }
public T Get <T>(object key, T defaultValue) { MDataCell cell = this[key]; if (cell == null || cell.IsNull) { return(defaultValue); } return(cell.Get <T>()); }
/// <summary> /// 此方法被Emit所调用 /// </summary> public object GetItemValue(int index)//必须Public { MDataCell cell = this[index]; if (cell == null || cell.Value == null || cell.Value == DBNull.Value) { return(null); } return(cell.Value); }
/// <summary> /// 为行设置值 /// </summary> /// <param name="key">字段名</param> /// <param name="value">值</param> /// <param name="state">手工设置状态[0:未更改;1:已赋值,值相同[可插入];2:已赋值,值不同[可更新]]</param> public MDataRow Set(object key, object value, int state) { MDataCell cell = this[key]; if (cell != null) { cell.Value = value; if (state > -1 && state < 3) { cell.State = state; } } return(this); }
/// <summary> /// 获取行的当前状态[0:未更改;1:已赋值,值相同[可插入];2:已赋值,值不同[可更新]] /// </summary> public int GetState(bool ignorePrimaryKey) { int state = 0; for (int i = 0; i < this.Count; i++) { MDataCell cell = this[i]; if (ignorePrimaryKey && cell.Struct.IsPrimaryKey) { continue; } state = cell.State > state ? cell.State : state; } return(state); }
/// <summary> /// 复制一行 /// </summary> /// <returns></returns> public MDataRow Clone() { MDataRow row = new MDataRow(); for (int i = 0; i < Count; i++) { MCellStruct mcb = this[i].Struct; MDataCell mdc = new MDataCell(ref mcb); mdc.LoadValue(this[i]); row.Add(mdc); } //row._Table = _Table;//不能带,会造成单行移除列时,移除的是原引用的行,而不是自身 row.RowError = RowError; row.TableName = TableName; row.Conn = Conn; return(row); }
internal MDataCell[] GetJoinPrimaryCell(MDataRow row) { MDataCell[] cells = null; if (jointPrimaryIndex != null && jointPrimaryIndex.Count > 0) { cells = new MDataCell[jointPrimaryIndex.Count]; for (int i = 0; i < jointPrimaryIndex.Count; i++) { cells[i] = row[jointPrimaryIndex[i]]; } } else { cells = row.JointPrimaryCell.ToArray(); } return(cells); }
/// <param name="columns"><para>批量指定某些列</para></param> /// <returns></returns> public MDataRow SetState(int state, BreakOp op, string columns) { if (!string.IsNullOrEmpty(columns)) { string[] items = columns.Trim(',', ' ').Split(','); for (int i = 0; i < items.Length; i++) { MDataCell cell = this[items[i]]; if (cell != null) { SetState(state, op, cell); } } } else { for (int i = 0; i < this.Count; i++) { SetState(state, op, this[i]); } } return(this); }
/// <summary> /// 多条件下值比较 /// </summary> private static bool CompareMore(MDataRow row, List <TFilter> filters) { if (row == null) { return(false); } bool result = false; MDataCell cell = null, otherCell = null; SqlDbType sqlDbType = SqlDbType.Int; //单个条件比较的结果 bool moreResult = false; object valueA = null, valueB = null; foreach (TFilter item in filters) { if (item._Op == Op.None || item._columnAIndex == -1) { moreResult = true;//如果条件的列不属于当前表,直接忽略该条件 } else { //if (item._columnAIndex == -1) //{ // moreResult = true; // continue; // //valueA = item._valueA; // //sqlDbType = SqlDbType.NVarChar; //} //else //{ cell = row[item._columnAIndex]; valueA = cell.Value; sqlDbType = cell.Struct.SqlType; //} #region MyRegion if (item._columnBIndex > -1) { otherCell = row[item._columnBIndex]; valueB = otherCell.Value; if (DataType.GetGroup(sqlDbType) != DataType.GetGroup(otherCell.Struct.SqlType)) { sqlDbType = SqlDbType.NVarChar;//不同类型的比较,转成字符串比较。 } } else { valueB = item._valueB; } switch (item._Op) { case Op.IsNull: moreResult = cell != null && cell.IsNull; break; case Op.IsNotNull: moreResult = cell != null && !cell.IsNull; break; default: if (Convert.ToString(valueA) == "" || Convert.ToString(valueB) == "") //空格的问题,稍后回来处理。 { #region MyRegion int a = valueA == null ? 1 : (Convert.ToString(valueA) == "" ? 2 : 3); int b = valueB == null ? 1 : (Convert.ToString(valueB) == "" ? 2 : 3); switch (item._Op) { case Op.Big: moreResult = a > b; break; case Op.Like: case Op.Equal: moreResult = a == b; break; case Op.SmallEqual: moreResult = a <= b; break; case Op.BigEqual: moreResult = a >= b; break; case Op.Small: moreResult = a < b; break; case Op.NotLike: case Op.NotEqual: moreResult = a != b; break; //case Op.In: // break; //case Op.NotIn: // break; } #endregion } else { moreResult = Compare(sqlDbType, valueA, item._Op, valueB); } break; } #endregion } switch (item._Ao) { case Ao.And: result = result && moreResult; if (!result) { break; } break; case Ao.Or: result = result || moreResult; break; default: result = moreResult; break; } } return(result); }
/// <summary> /// 值比较 /// </summary> private static bool CompareMore(MDataRow row, params TFilter[] filters) { if (row == null) { return(false); } bool result = false; MDataCell cell = null, otherCell = null; SqlDbType sqlDbType = SqlDbType.Int; bool moreResult = false; object valueA = null, valueB = null; foreach (TFilter item in filters) { if (item._Op == Op.None) { moreResult = true; } else { if (item._columnAIndex == -1) { valueA = item._valueA; sqlDbType = SqlDbType.NVarChar; } else { cell = row[item._columnAIndex]; valueA = cell.Value; sqlDbType = cell.Struct.SqlType; } if (item._columnBIndex > -1) { otherCell = row[item._columnBIndex]; valueB = otherCell.Value; if (DataType.GetGroup(sqlDbType) != DataType.GetGroup(otherCell.Struct.SqlType)) { sqlDbType = SqlDbType.NVarChar;//不同类型的比较,转成字符串比较。 } } else { valueB = item._valueB; } switch (item._Op) { case Op.IsNull: moreResult = cell != null && cell.IsNull; break; case Op.IsNotNull: moreResult = cell != null && !cell.IsNull; break; default: if (Convert.ToString(valueA) == "" || Convert.ToString(valueB) == "") //空格的问题,稍后回来处理。 { int a = valueA == null ? 1 : (Convert.ToString(valueA) == "" ? 2 : 3); int b = valueB == null ? 1 : (Convert.ToString(valueB) == "" ? 2 : 3); switch (item._Op) { case Op.Big: moreResult = a > b; break; case Op.Like: case Op.Equal: moreResult = a == b; break; case Op.SmallEqual: moreResult = a <= b; break; case Op.BigEqual: moreResult = a >= b; break; case Op.Small: moreResult = a < b; break; case Op.NotEqual: moreResult = a != b; break; //case Op.In: // break; //case Op.NotIn: // break; } } else { moreResult = Compare(sqlDbType, valueA, item._Op, valueB); } break; } } switch (item._Ao) { case Ao.And: result = result && moreResult; break; case Ao.Or: result = result || moreResult; break; default: result = moreResult; break; } } return(result); }
public MDataProperty(MDataCell mdc, Attribute[] attrs) : base(mdc.ColumnName, attrs) { cell = mdc; }
internal void LoadValue(MDataCell cell, bool isWithState) { isNewValue = true; CellValue.LoadValue(cell.CellValue, isWithState); }