ahmedsalah
Active member
- Joined
- Sep 26, 2018
- Messages
- 32
- Programming Experience
- 3-5
I work on .net core 6 vs 2022 i see function have telement
but i don't know what this mean
can you show me please ?
and when use it
are there are any thing best from using telement or more general
What I have tried:
but i don't know what this mean
can you show me please ?
and when use it
are there are any thing best from using telement or more general
What I have tried:
what mean Telement and why use it:
public List<TElement> SQLQuery<TElement>(string sql, string? connectionStringName = null, params StoredParameter[] parameters)
{
string ConnectionString = connectionStringName == null ? _ApplicationConfiguration.ConnectionString : _ApplicationConfiguration.GetConnectionString(connectionStringName);
using (SqlConnection sqlConn = new SqlConnection(ConnectionString))
{
using (SqlCommand cmd = new SqlCommand(sql, sqlConn))
{
cmd.CommandText = sql;
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandTimeout = (int)TimeSpan.FromMinutes(5).TotalSeconds;
//cmd.Parameters.AddRange(parameters);
foreach (var parameter in parameters)
{
var paramter = cmd.CreateParameter();
paramter.ParameterName = parameter.ParameterName;
paramter.Value = parameter.ParameterValue;
if (!string.IsNullOrEmpty(parameter.TypeName))
{
paramter.SqlDbType = SqlDbType.Structured;
paramter.TypeName = parameter.TypeName;
}
cmd.Parameters.Add(paramter);
}
sqlConn.Open();
using (var reader = cmd.ExecuteReader())
{
var result = reader.MapToList<TElement>();
sqlConn.Close();
return result;
}
}
}