Added function to MySqlSession to check if a row exists. Bumped package version to 1.1.4

This commit is contained in:
MattMo 2023-06-23 10:10:17 -07:00
parent 8cf3b2eac0
commit cabbdc847a
2 changed files with 37 additions and 1 deletions

@ -7,7 +7,7 @@
<AssemblyName>MontoyaTech.MySqlPlus</AssemblyName>
<RootNamespace>MontoyaTech.MySqlPlus</RootNamespace>
<Title>MontoyaTech.MySqlPlus</Title>
<Version>1.1.3</Version>
<Version>1.1.4</Version>
<Company>MontoyaTech</Company>
<Description>A simple C# library to help work with MySql.</Description>
<Copyright>MontoyaTech 2023</Copyright>

@ -145,6 +145,42 @@ namespace MontoyaTech.MySqlPlus
}
}
/// <summary>
/// Returns whether or not a row of a given type exists by id in the db.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id"></param>
/// <returns></returns>
public bool Exists<T>(ulong id)
{
using (var command = new MySqlCommand())
{
command.Exists<T>(id);
using (var reader = this.Connection.ExecuteReader(command))
return reader.GetBoolean(0);
}
}
/// <summary>
/// Returns whether or not a row of a given type exists by id in the db.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id"></param>
/// <returns></returns>
public bool Exists<T>(string id)
{
using (var command = new MySqlCommand())
{
command.Exists<T>(id);
using (var reader = this.Connection.ExecuteReader(command))
return reader.GetBoolean(0);
}
}
/// <summary>
/// Deletes a row in the db.
/// </summary>