You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
800 B
26 lines
800 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BiskLog_Point_Of_Sale.Classes
|
|
{
|
|
public static class SqlCommandExtensions
|
|
{
|
|
public static void AddParametersWithValues<T>(this SqlCommand cmd, string parameterName, params T[] values)
|
|
{
|
|
var parameterNames = new List<string>();
|
|
for (int i = 0; i < values.Count(); i++)
|
|
{
|
|
var paramName = @"@products" + i;
|
|
cmd.Parameters.AddWithValue(paramName, values.ElementAt(i));
|
|
parameterNames.Add(paramName);
|
|
}
|
|
|
|
cmd.CommandText = cmd.CommandText.Replace(parameterName, string.Join(",", parameterNames));
|
|
}
|
|
|
|
}
|
|
}
|
|
|