CodeLiturgy.Dashboard/CodeLiturgy.Domain/Templates/GetOneByTemplate.csx

15 lines
765 B
Plaintext
Raw Normal View History

2022-09-05 05:58:37 +03:00
/// <summary>
2022-09-06 00:42:45 +03:00
/// Gets the first result in the table, and returns a projection of <see cref="{returnTypeFullName}"></see>
2022-09-05 05:58:37 +03:00
/// </summary>
/// <param name="dbContext">The database context.</param>
2022-09-06 01:37:52 +03:00
/// <param name="{byParamVarName}">By {byParamPropertyName} parameter type.</param>
2022-09-09 06:26:16 +03:00
/// <returns>A projection of {entityTypeName}> </returns>
2022-09-05 05:58:37 +03:00
public static (bool, {returnTypeFullName}) GetOne{entityTypeName}By{byParamPropertyName} (this {contextFullName} dbContext, {byParamFullType} {byParamVarName})
{
var {findEntityVarName} = dbContext.{propertyName}
.Where(x => x.{byParamPropertyName} == {byParamVarName})
.Select(x => new {returnTypeFullName}(x))
.FirstOrDefault();
return ({findEntityVarName} != null, {findEntityVarName});
}