HighwayFramework / Highway.Data

The fastest and smoothest way to great architecture

Home Page:http://hwyfwk.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Highway.Data Async

opened this issue · comments

I am looking to implement Async with my queries and commands, but haven't been able to find any updated information on this. The only thing I saw was some documentation from version 1.0.1.0 found here: .

Am I correct to assume this is the way to implement an async query?

public class FindClient : Scalar<Task>
{
public FindClient(string clientId)
{
ContextQuery = cq => cq.AsQueryable().SingleOrDefaultAsync(a => a.Id == clientId);
}
}

I was not able to figure out how to write an async command. If this is possible, can you please give me an example?

Any ideas?

I am still having issues with this along with trying to unit test my async queries. I tried implementing the following link from msdn, but haven't had any luck.

https://msdn.microsoft.com/en-us/data/dn314429#async

The Async repository and context are targeted to the 6.0 release schedule later this week. I'll post a link here when the code is on the pre-release branch.

Repository now has Async usage on your standard queries in release 6-0
https://github.com/HighwayFramework/Highway.Data/tree/release-6-0

Like
var results = await repo.FindAsync(new YourExistingQuery());

Devlin,

Thank you very much for this update.

There may have been a bug introduced. A third of my unit tests started
failing when I moved to the 6.0 release with the following error: Non-static
method requires a target

It seems to be coming from the addMethod.Invoke(collection, new[] {
rep.Entity }); (line 89)
call in the UpdateExistingRepresentations method
of the ObjectRepresentationRepository class.

Here is a stack overflow Q&A that may help:

http://stackoverflow.com/questions/4577191/non-static-method-requires-a-target-c-sharp

Let me know if there is anything else you might need from me.

Thanks in advance,

*Andrew J. Petersen *| (225) 317-9660
www.bluefindata.com http://bluefindata.com

On Mon, Mar 16, 2015 at 11:31 AM, Devlin Liles notifications@github.com
wrote:

Repository now has Async usage on your standard queries in release 6-0
https://github.com/HighwayFramework/Highway.Data/tree/release-6-0

Like
var results = await repo.FindAsync(new YourExistingQuery());


Reply to this email directly or view it on GitHub
#76 (comment)
.

Can you send me an example test that is failing? Release 6.0 is still being worked on. My hope is to have it out this month with all tests passing and the regression tests done.

Sure thing, attached is the query and test file.

Let me know if there is anything else I can do.

Thanks,

*Andrew J. Petersen *| (225) 317-9660
www.bluefindata.com http://bluefindata.com

On Fri, May 8, 2015 at 9:44 AM, Devlin Liles notifications@github.com
wrote:

Reopened #76 #76.


Reply to this email directly or view it on GitHub
#76 (comment)
.

public class GetReportTypes : Scalar<List>
{
public GetReportTypes(string userId)
{

    ContextQuery = cq => cq.AsQueryable<ReportType>()
                                            .Where(x => x.Agency.AgencyUsers.Any(au => au.UserId == userId))
                                            .Project().To<ReportTypeModel>().ToList();
}

}
[TestMethod]
public void SetReportTypesName_ReturnsModelsNameEqualsExpected()
{
//Arrange
const string expected = "reportType1";

var agency = new Agency { AgencyUsers = new List<AgencyUser> { new AgencyUser() } };

Context.Add(new ReportType {Name = expected, Agency = agency });
Context.Commit();

//Act
var results = Repository.Find(new GetReportTypes(""));

//Assert
results.Single().Name.ShouldBeEqual(expected);

}

Devlin,

I may have found some more info in order to help you find this issue. It
seems it has something to do with Context.Add() & Context.Commit(). I was
able to comment out the query and still receive the error.

I was able to get around the error by assigning the Agency's ReportTypes
property to an empty list. See the updated test attached.

Agency has a one to many relationship with Report Type.

I hope this helps.

Thanks,

*Andrew J. Petersen *| (225) 317-9660
www.bluefindata.com http://bluefindata.com

On Mon, May 11, 2015 at 3:17 PM, Andrew Petersen andrew@bluefindata.com
wrote:

Sure thing, attached is the query and test file.

Let me know if there is anything else I can do.

Thanks,

*Andrew J. Petersen *| (225) 317-9660
www.bluefindata.com http://bluefindata.com

On Fri, May 8, 2015 at 9:44 AM, Devlin Liles notifications@github.com
wrote:

Reopened #76 #76
.


Reply to this email directly or view it on GitHub
#76 (comment)
.

[TestMethod]
public void SetReportTypesName_ReturnsModelsNameEqualsExpected()
{
//Arrange
const string expected = "reportType1";

var agency = new Agency { ReportTypes = new List<ReportType>(), AgencyUsers = new List<AgencyUser> { new AgencyUser() } };

Context.Add(new ReportType {Name = expected, Agency = agency });
Context.Commit();

//Act
//var results = Repository.Find(new GetReportTypes(""));

//Assert
//results.Single().Name.ShouldBeEqual(expected);

}

take a look at what is on release-6-0 and see if that would work for you. Repository.FindAsync(new GetReportTypes(""));

This is in package 6.0.1

Devlin,

Was this error fixed?

I am still getting the error Non-static method required a target error
after upgrading to 6.0.1.

*Andrew J. Petersen *| (225) 317-9660
www.bluefindata.com http://bluefindata.com

On Tue, Jul 7, 2015 at 8:43 AM, Devlin Liles notifications@github.com
wrote:

Closed #76 #76.


Reply to this email directly or view it on GitHub
#76 (comment)
.