Added function to MySqlSession to check if a row exists. Bumped package version to 1.1.4
This commit is contained in:
parent
8cf3b2eac0
commit
cabbdc847a
MySqlPlus
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user