public static void SetParameterFromMemberNonNullableString <T>(this GeneratedMethod method, int index, Expression <Func <T, string> > memberExpression) { var member = FindMembers.Determine(memberExpression).Single(); method.Frames.Code($"parameters[{index}].Value = {{0}}.{member.Name};", Use.Type <T>()); method.Frames.Code($"parameters[{index}].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text;"); }
public static void AssignMemberFromReaderAsync <T>(this GeneratedMethod method, GeneratedType generatedType, int index, Expression <Func <T, object> > memberExpression) { var member = FindMembers.Determine(memberExpression).Single(); var variableName = member.Name.ToCamelCase(); method.Frames.Code($"var {variableName} = await reader.GetFieldValueAsync<{member.GetMemberType().FullNameInCode()}>({index}, {{0}});", Use.Type <CancellationToken>()); method.Frames.SetMemberValue(member, variableName, typeof(T), generatedType); }
public static void SetParameterFromMember <T>(this GeneratedMethod method, int index, Expression <Func <T, object> > memberExpression) { var member = FindMembers.Determine(memberExpression).Single(); var memberType = member.GetMemberType(); var pgType = TypeMappings.ToDbType(memberType); if (memberType == typeof(string)) { method.Frames.Code($"parameters[{index}].Value = {{0}}.{member.Name} != null ? (object){{0}}.{member.Name} : {typeof(DBNull).FullNameInCode()}.Value;", Use.Type <T>()); method.Frames.Code($"parameters[{index}].NpgsqlDbType = {{0}};", pgType); } else { method.Frames.Code($"parameters[{index}].Value = {{0}}.{member.Name};", Use.Type <T>()); method.Frames.Code($"parameters[{index}].NpgsqlDbType = {{0}};", pgType); } }