public (Dictionary <string, string>, Dictionary <string, Stream>) ConvertToDictionaries() { Validate(); return(new Dictionary <string, string> { ["image_url"] = ImageUrl, ["image_base64"] = ImageBase64, ["return_landmark"] = ((int)ReturnLandmark).ToString(), ["return_attributes"] = ReturnAttributes.ToString().ToLower().Replace(" ", ""), ["calculate_all"] = CalculateAll.HasValue ? (CalculateAll.Value ? "1" : "0") : null, ["face_rectangle"] = FaceRectangle?.ToString() }, new Dictionary <string, Stream> { ["image_file"] = ImageFile }); }
public string AsSqlString() { var toInsert = InsertAbleAttributes.Select(attr => attr.DataBaseColumn) .Aggregate("", (acc, next) => acc == "" ? next : acc + ", " + next); var insertPositions = InsertAbleAttributes.Aggregate("", (acc, next) => acc == "" ? $"@{next.DataBaseColumn}?" : acc + ", " + $"@{next.DataBaseColumn}?"); var insertPlaceHolder = InsertedObjects.Select((s, i) => (i, s)).Aggregate("", (acc, next) => acc == "" ? $"({insertPositions.Replace("?", ""+next.i)})" : acc + $", ({insertPositions.Replace("?", ""+next.i)})"); var returnValues = ReturnAttributes .Select(attr => attr.DataBaseColumn) .Aggregate("", (acc, next) => acc == "" ? next : acc + ", " + next); return($"INSERT INTO {Entity.TableName} ({toInsert}) " + $"VALUES {insertPlaceHolder} " + $"RETURNING {returnValues}"); }