Beispiel #1
0
        public static DbCommand AddParameters(this DbCommand dbCommand, DataSourceParameters parameters)
        {
            Argument.IsNotNull(() => dbCommand);

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

            return(dbCommand);
        }
Beispiel #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()));
        }
Beispiel #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);
 }
Beispiel #4
0
 public static bool IsEmpty(this DataSourceParameters databaseQueryParameters)
 {
     return(databaseQueryParameters?.Parameters is null || !databaseQueryParameters.Parameters.Any());
 }
Beispiel #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);
 }