Hi,
I would like to Create a single record in my database (PK is identity auto generated) and return that record on creation so I can do something with it.
How can I do this easily with the SDK?
CreateRecordsAsync asks me for a query to return records on creation, I will not know my PKID in advance?
Ideally, I would like Task CreateRecordAsync(string tableName, TRecord record)
If I fork the repository will you accept pull request in future if I make any useful updates?
Thanks
Matt
FYI, Existing GitHub SDK Code -
public async Task<IEnumerable> CreateRecordsAsync(string tableName, IEnumerable records, SqlQuery query)
{
if (tableName == null)
throw new ArgumentNullException(“tableName”);
if (records == null)
throw new ArgumentNullException(“records”);
if (query == null)
throw new ArgumentNullException(“query”);
IHttpAddress address = this.baseAddress.WithResource(tableName);
address = HttpAddressExtensions.WithSqlQuery(address, query);
var recordsRequest = new
{
record = Enumerable.ToList(records)
};
string data = this.contentSerializer.Serialize(recordsRequest);
IHttpRequest request = (IHttpRequest) new HttpRequest(HttpMethod.Post, address.Build(), this.baseHeaders, data);
IHttpResponse response = await this.httpFacade.RequestAsync(request);
HttpUtils.ThrowOnBadStatus(response, this.contentSerializer);
return (IEnumerable) this.contentSerializer.Deserialize(response.Body, recordsRequest).record;
}