Skip to content

Interface IDbParamsProvider

Namespace: Momentum.Extensions.Abstractions.Dapper
Assembly: Momentum.Extensions.Abstractions.dll

Defines a contract for objects that can provide database parameters for Dapper queries.

csharp
public interface IDbParamsProvider

Remarks

Implement this interface on command or query objects to provide a custom mapping between the object's properties and database parameters. This is particularly useful when the object structure doesn't directly match the expected database parameters.

Methods

ToDbParams()

Converts the current object to a database parameter object.

csharp
object ToDbParams()

Returns

object

An object containing the parameters to be used in a database query. This is typically an anonymous object or a dynamic object with properties matching the parameter names expected by the SQL query.

Examples

public object ToDbParams() => new
{
    Id = this.UserId,
    Name = this.UserName,
    CreatedAt = DateTime.UtcNow
};