//----------------------------------------------------------------// public virtual Task <T> GetItem(TKey key) { bool isClustered = SqlGenerateHelper.IsClustered <T>(); string condition = SqlGenerateHelper.GenerateUniqueCondition <T, TKey>(nameof(key), isClustered); string getItem = $"SELECT TOP 1 * FROM {TableName} WHERE {condition}"; return(_connection.QueryFirstOrDefaultAsync <T>(getItem, SqlGenerateHelper.CreatePrimaryKeyParameter(key, isClustered), _transaction, _connection.ConnectionTimeout)); }
//----------------------------------------------------------------// public async virtual Task <bool> IsItemExist(TKey key) { bool isClustered = SqlGenerateHelper.IsClustered <T>(); string condition = SqlGenerateHelper.GenerateUniqueCondition <T, TKey>(nameof(key), isClustered); string itemExist = $"SELECT COUNT(*) FROM {TableName} WHERE {condition}"; return(await _connection.QueryFirstOrDefaultAsync <int>(itemExist, SqlGenerateHelper.CreatePrimaryKeyParameter(key, isClustered), _transaction, _connection.ConnectionTimeout) > default(int)); }
//----------------------------------------------------------------// public bool Delete(TKey key) { bool isClustered = SqlGenerateHelper.IsClustered <T>(); string condition = SqlGenerateHelper.GenerateUniqueCondition <T, TKey>(nameof(key), isClustered); string deleteEntity = $"DELETE {TableName} WHERE {condition}"; return(_connection.Execute(condition, SqlGenerateHelper.CreatePrimaryKeyParameter(key, isClustered)) > default(int)); }