From 34b203876b91e9bee1d3339565fbb18a23f02cb8 Mon Sep 17 00:00:00 2001 From: Manel Bosch Hermosilla Date: Thu, 5 May 2022 14:15:51 +0200 Subject: [PATCH] Documented the Get/GetAsync behaviour when no record is found. --- Dapper.SimpleCRUD/SimpleCRUD.cs | 2 +- Dapper.SimpleCRUD/SimpleCRUDAsync.cs | 2 +- README.md | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dapper.SimpleCRUD/SimpleCRUD.cs b/Dapper.SimpleCRUD/SimpleCRUD.cs index 691075c..622b05c 100644 --- a/Dapper.SimpleCRUD/SimpleCRUD.cs +++ b/Dapper.SimpleCRUD/SimpleCRUD.cs @@ -143,7 +143,7 @@ public static void SetColumnNameResolver(IColumnNameResolver resolver) /// /// /// - /// Returns a single entity by a single id from table T. + /// Returns a single entity by a single id from table T or default(T) if no entity is found. public static T Get(this IDbConnection connection, object id, IDbTransaction transaction = null, int? commandTimeout = null) { var currenttype = typeof(T); diff --git a/Dapper.SimpleCRUD/SimpleCRUDAsync.cs b/Dapper.SimpleCRUD/SimpleCRUDAsync.cs index ff70770..cf4d496 100644 --- a/Dapper.SimpleCRUD/SimpleCRUDAsync.cs +++ b/Dapper.SimpleCRUD/SimpleCRUDAsync.cs @@ -26,7 +26,7 @@ public static partial class SimpleCRUD /// /// /// - /// Returns a single entity by a single id from table T. + /// Returns a single entity by a single id from table T or default(T) if no entity is found. public static async Task GetAsync(this IDbConnection connection, object id, IDbTransaction transaction = null, int? commandTimeout = null) { var currenttype = typeof(T); diff --git a/README.md b/README.md index 5766468..7cd0a51 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ Notes: - The [Column] attribute can be used from the Dapper namespace, System.ComponentModel.DataAnnotations.Schema, or System.Data.Linq.Mapping - By default the column name will match the property name but it can be overridden with this. You can even use the model property names in the where clause anonymous object and SimpleCRUD will generate a proper where clause to match the database based on the column attribute - GUID (uniqueidentifier) primary keys are supported (autopopulates if no value is passed in) +- If no record is found the default value of the given type ( `default(T)` ) is returned. Execute a query and map the results to a strongly typed List ------------------------------------------------------------