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

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

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