Simple.Data with async /await

90 views
Skip to first unread message

Sabrina

unread,
Dec 11, 2015, 9:59:11 AM12/11/15
to Simple.Data
Hi, all:

I am fairly new to Simple.Data. I am trying to use OWIN middleware with WebAPI , using Simple.Data as backend. 

If I use it synchronously to get data from Simple.Data, it works fine, but if I use async/await pattern, it fails. Does Simple.Data not work with async/await? I searched the group, there was a similar question 3 years ago and Mark mentioned that would be worked in a month, so I thought it should have worked.

the error message is: 
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Table 'dbo.GetAwaiter' not found, or insufficient permissions.
</ExceptionMessage>
<ExceptionType>Simple.Data.UnresolvableObjectException</ExceptionType>
<StackTrace>
at Simple.Data.Ado.Schema.TableCollection.Find(String tableName, String schemaName) at Simple.Data.Ado.Schema.TableCollection.Find(String tableName) at Simple.Data.Ado.Schema.DatabaseSchema.FindTable(String tableName) at Simple.Data.Ado.Schema.Table.GetMaster(String name) at Simple.Data.Ado.AdoAdapterRelatedFinder.TryMasterJoin(String tableName, String relatedTableName) at Simple.Data.Ado.AdoAdapterRelatedFinder.<TryJoin>b__2(Tuple`2 t) at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) at Simple.Data.Ado.AdoAdapterRelatedFinder.TryJoin(String tableName, String relatedTableName) at Simple.Data.Ado.AdoAdapter.IsValidRelation(String tableName, String relatedTableName) at Simple.Data.SimpleRecord.TryGetMember(GetMemberBinder binder, Object& result)
</StackTrace>
</InnerException>


here is the code snippet:

<code>

this is in a webapi controller: 
 public async Task<Company>  Get(int id)
        {
            var connStr = ConfigurationManager.ConnectionStrings["my-db"].ConnectionString;
            var db = Database.OpenConnection(connStr);
            Company temp = db.Company.Get(1); // this is getting the right company
             Company company = await db.Company.Get(1);
            if (company == null)
                throw new HttpResponseException(
                    System.Net.HttpStatusCode.NotFound);
            return company;
        }


this is from a console client : 
 public HttpClient CreateClient()
        {
            var client = new HttpClient();
            client.BaseAddress = new Uri(new Uri(_hostUri), "api/companies/");
            return client;
        }

   public Company GetCompany(int id)
        {
            HttpResponseMessage response;
            using (var client = CreateClient())
            {
                response = client.GetAsync(new Uri(client.BaseAddress, id.ToString())).Result;
            }   

            var result = response.Content.ReadAsStringAsync()
                .ContinueWith(c => JsonConvert.DeserializeObject<Company>(c.Result));

            return result.Result;
        }

</code>

Can anyone help with async stuff?  I can also post the github link so that you can play with the code if needed. Thanks

Sabrina

Ben Magyar

unread,
Dec 23, 2015, 11:29:53 AM12/23/15
to Simple.Data
I believe async/await was scheduled for v2, not so much v1. 
Reply all
Reply to author
Forward
0 new messages