private TypeMapRule getRule(DataType dataType) { foreach(TypeMapRule rule in rules) { bool match = (rule.FromType == dataType.Name) && (rule.FromPrecision == dataType.Precision.ToString() || rule.FromPrecision == "*") && (rule.FromScale == dataType.Scale.ToString() || rule.FromScale == "*"); if (match) { return rule; } } return null; }
public DataType MapDataType(DataType fromDataType) { TypeMapRule rule = getRule(fromDataType); if (rule == null) { return fromDataType.Clone(); } DataType dt = new DataType(); dt.Name = rule.ToType; if (string.IsNullOrEmpty(rule.ToPrecision)) { dt.Precision = null; } else if (rule.ToPrecision == "=") { dt.Precision = fromDataType.Precision; } else { dt.Precision = long.Parse(rule.ToPrecision); } if (string.IsNullOrEmpty(rule.ToScale)) { dt.Scale = null; } else if (rule.ToScale == "=") { dt.Scale = fromDataType.Scale; } else { dt.Scale = long.Parse(rule.ToScale); } return dt; }
public DataType Clone() { DataType dt = new DataType(this.Name, this.Precision, this.Scale); return dt; }