.Net SDK Single Record Create and Return

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;
}

Hi Matt,

I’m in process of updating the SDK API so any input regarding the signature of methods is greatly appreciated, and will be taken in consideration for further development.

Regarding your example, query object in this particular instance does not define filter for records like in Get request, it only defines which fields you would like to have returned.

Currently to create a single new record you want to call the method with your record as the first element in a collection and new SqlQuery() as query argument because parameterless constructor of SqlQuery sets Fields to “*” which returns all fields of created record.

Hope this helps,

Regards
Marko

Thanks Marko for clarifying that behaviour, I was confused as you can tell.

I will continue using the API over the coming weeks (only just started as you can tell) and definitely provide feedback if I think I can help.

Regards
Matt