private void FillParamInfo(IQueryParamInfo qp, string name, string sqlTypeAndLength) { string typeOnly; int len = 0; if (sqlTypeAndLength.IndexOf('(') > 0) { typeOnly = sqlTypeAndLength.Substring(0, sqlTypeAndLength.IndexOf('(')); if (typesWithLength.Contains(typeOnly.ToLower())) { int.TryParse(Regex.Match(sqlTypeAndLength, "(?<=\\()\\s*(?'myInt'\\d*)").Groups["myInt"].Value, out len); } } else { typeOnly = sqlTypeAndLength; } string normalizedType; var csType = TypeMapDB2CS(typeOnly, out normalizedType); qp.CSType = csType; qp.DbType = normalizedType; qp.Length = len; qp.CSName = name; qp.DbName = '@' + name; }
private void FillParamInfo(IQueryParamInfo qp, string name, string sqlTypeAndLength) { var m = Regex.Match(sqlTypeAndLength, @"(?'type'^\w*)\(?(?'firstNum'\d*),?(?'secondNum'\d*)"); var typeOnly = m.Groups["type"].Value; int.TryParse(m.Groups["firstNum"].Value, out int firstNum); int.TryParse(m.Groups["secondNum"].Value, out int secondNum); if (secondNum != 0) { qp.Precision = firstNum; qp.Scale = secondNum; } else if (typeOnly.ToLower() == "datetime2") { qp.Precision = firstNum; } else if (firstNum > 0) { qp.Length = firstNum; } string normalizedType; var csType = TypeMapDB2CS(typeOnly, out normalizedType); qp.CSType = csType; qp.DbType = normalizedType; qp.CSName = name; qp.DbName = '@' + name; }
private void FillParamInfo(IQueryParamInfo qp, string name, string sqlTypeAndLength) { string typeOnly; int len = 0; if (sqlTypeAndLength.IndexOf('(') > 0) { typeOnly = sqlTypeAndLength.Substring(0, sqlTypeAndLength.IndexOf('(')); len = int.Parse(sqlTypeAndLength.Substring(sqlTypeAndLength.IndexOf('(') + 1, sqlTypeAndLength.Length - sqlTypeAndLength.IndexOf('(') - 2)); } else { typeOnly = sqlTypeAndLength; } string normalizedType; var csType = TypeMapDB2CS(typeOnly, out normalizedType); qp.CSType = csType; qp.DbType = normalizedType; qp.Length = len; qp.CSName = name; qp.DbName = '@' + name; }