Skip to content

Commit

Permalink
#857 - Added the necessary attributes for the MDS.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikependon committed Sep 11, 2021
1 parent b6e77a7 commit edafa5a
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Data.SqlClient;

namespace RepoDb.Attributes
{
/// <summary>
/// An attribute used to define a value to the <see cref="SqlParameter.Offset"/> property via an entity property
/// before the actual execution.
/// </summary>
public class SqlParameterOffsetAttribute : ParameterPropertyValueSetterAttribute
{
/// <summary>
/// Creates a new instance of <see cref="SqlParameterOffsetAttribute"/> class.
/// </summary>
/// <param name="offset">The offset value.</param>
public SqlParameterOffsetAttribute(int offset)
: base(typeof(SqlParameter), nameof(SqlParameter.Offset), offset)
{ }

/// <summary>
/// Gets a type name that is currently mapped.
/// </summary>
public int Offset => (int)Value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.Data.SqlClient;
using System.Data;

namespace RepoDb.Attributes
{
/// <summary>
/// An attribute used to define a value to the <see cref="SqlParameter.SqlDbType"/> property via an entity property
/// before the actual execution.
/// </summary>
public class SqlParameterSqlDbTypeAttribute : ParameterPropertyValueSetterAttribute
{
/// <summary>
/// Creates a new instance of <see cref="SqlParameterSqlDbTypeAttribute"/> class.
/// </summary>
/// <param name="sqlDbType">The value of the target <see cref="System.Data.SqlDbType"/>.</param>
public SqlParameterSqlDbTypeAttribute(SqlDbType sqlDbType)
: base(typeof(SqlParameter), nameof(SqlParameter.SqlDbType), sqlDbType)
{ }

/// <summary>
/// Gets a <see cref="System.Data.SqlDbType"/> that is currently mapped.
/// </summary>
public SqlDbType SqlDbType => (SqlDbType)Value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Data.SqlClient;

namespace RepoDb.Attributes
{
/// <summary>
/// An attribute used to define a value to the <see cref="SqlParameter.TypeName"/> property via an entity property
/// before the actual execution.
/// </summary>
public class SqlParameterTypeNameAttribute : ParameterPropertyValueSetterAttribute
{
/// <summary>
/// Creates a new instance of <see cref="SqlParameterTypeNameAttribute"/> class.
/// </summary>
/// <param name="typeName">The name of the type.</param>
public SqlParameterTypeNameAttribute(string typeName)
: base(typeof(SqlParameter), nameof(SqlParameter.TypeName), typeName)
{ }

/// <summary>
/// Gets a type name that is currently mapped.
/// </summary>
public string TypeName => (string)Value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Data.SqlClient;

namespace RepoDb.Attributes
{
/// <summary>
/// An attribute used to define a value to the <see cref="SqlParameter.UdtTypeName"/> property via an entity property
/// before the actual execution.
/// </summary>
public class SqlParameterUdtTypeNameAttribute : ParameterPropertyValueSetterAttribute
{
/// <summary>
/// Creates a new instance of <see cref="SqlParameterTypeNameAttribute"/> class.
/// </summary>
/// <param name="udtTypeName">The name of the UTD.</param>
public SqlParameterUdtTypeNameAttribute(string udtTypeName)
: base(typeof(SqlParameter), nameof(SqlParameter.UdtTypeName), udtTypeName)
{ }

/// <summary>
/// Gets a type name that is currently mapped.
/// </summary>
public string UdtTypeName => (string)Value;
}
}

0 comments on commit edafa5a

Please sign in to comment.