Пример #1
0
        public static DbCommand AddParameters(this DbCommand dbCommand, DataSourceParameters parameters)
        {
            Argument.IsNotNull(() => dbCommand);

            parameters?.Parameters?.ForEach(x => dbCommand.AddParameter(x));

            return(dbCommand);
        }
Пример #2
0
        public static bool IsSameAs(this DataSourceParameters databaseQueryParameters, DataSourceParameters other)
        {
            if (ReferenceEquals(databaseQueryParameters, other))
            {
                return(true);
            }

            if (databaseQueryParameters.IsEmpty() && other.IsEmpty())
            {
                return(true);
            }

            var parameters      = databaseQueryParameters?.Parameters;
            var otherParameters = other?.Parameters;

            if (parameters is null || otherParameters is null)
            {
                return(false);
            }

            return(parameters.SequenceEqual(otherParameters, new NameAndTypeEqualsEqualyComparer()));
        }
Пример #3
0
 public static string ToArgsNamesString(this DataSourceParameters queryParameters, string argsPrefix = "")
 {
     return(queryParameters is not null?string.Join(",", queryParameters.Parameters?.Select(x => $"{argsPrefix}{x.Name}") ?? new List <string>()) : string.Empty);
 }
Пример #4
0
 public static bool IsEmpty(this DataSourceParameters databaseQueryParameters)
 {
     return(databaseQueryParameters?.Parameters is null || !databaseQueryParameters.Parameters.Any());
 }
Пример #5
0
 public static string ToArgsValueString(this DataSourceParameters queryParameters)
 {
     return(queryParameters is not null?string.Join(",", queryParameters.Parameters?.Select(x => $"'{x.Value}'") ?? new List <string>()) : string.Empty);
 }