Conversation
RheingoldRiver
left a comment
There was a problem hiding this comment.
Added a couple notes about the api interface
|
I think this PR can conclude here and we can start another one in 2021 so as to address the limitations. I've published the package on NuGet registry: CXuesong.MW.WikiClientLibrary.Cargo v0.7.4-int.0 and you can try it out a bit. |
|
So, after testing it for a while I have a couple of questions:
public async Task GetAsync()
{
await wikiSite.Initialization;
var context = new QueryContext(wikiSite);
var query = context.RosterChanges
.Where(x => x.Date_Sort > new DateTime(2020, 12, 11))
.OrderBy(x => x.Date_Sort)
.Select(x => new
{
x.Player,
x.Date_Sort,
}).Take(100);
var response = await query.AsAsyncEnumerable().ToListAsync();
}I noticed that results seem to be ordered by the first property I specified which was the player's name in this table and that results also seem to be repeating to fill in the specified limit. Also, this is a very memory intensive task, there's a lot of GC going on.
|
It's a bug. I've fixed it and published
Yeah. I've not done profiling so it's very possible that it has significant memory footprint. I'll let it be for now until '21 😂
Actually if you do not limit the size of result set in Entity Framework, you'll possible run into the same result. The point is, the public API let you treat the result set as a Under the hood, I'm currently paginating the result set per 10 records, so after every 10 records, WCL will ask server for the next batch. I'm planning to make the pagination size adjustable in the next PR. In addition, I've introduced a sample project under Here is some sample output Details |
|
Yep, working great so far. I'll make sure to test all the possible combinations of queries soon.
It is more of a code cleanup for the end user and would resemble more of EF Core's usage. I guess it would only make sense if it were returning an |
|
Hey, for the LINQ support, Cargo has one special operator you can use in |
@BrunoBlanes Actually ExecuteCargoQueryAsync is the counterpart of And frankly speaking, the async extension method support for
context.Skins.First() // Enumerable.First(IEnumerable<T>)
context.Skins.Take(10).ToArray() // Enumerable.ToArray(IEnumerable<T>)because we don't want synchronous blocking call in async functions.
Though it may sound a bit frustrating, but I'm not implementing async extension methods like
This means you will have to use something like this if you want to call some Linq collection (i.e. "collecting") methods cargoContext.Skins
.Take(10) // IQueryable, no access to ToListAsync
.AsAsyncEnumerable() // This function is provided by WikiClientLibrary. It casts the IQueryable to IAsyncEnumerable
// Do not confuse it with `ToAsyncEnumerable`!
.ToListAsync() // Calls the collection method from Ix.AsyncIf you are also referencing EF Core library, then I suppose the following usage should also do, but I have not ever tried it before. cargoContext.Skins
.Take(10) // IQueryable
.ToListAsync() // Calls the collection method provided by EF Core |
@RheingoldRiver Yeah I have that in mind. I think I can implement some stub method like |
Not completed yet.

Resolves dotnet/roslyn#77. See unit tests in
CargoTests.csfor usage example. Note that the public API inWikiClientLibrary.Cargo.Linqmay change dramatically in the future.action=cargoqueryrequest.Select,.Where,.OrderBy)TableAttribute(Schemais not supported)ColumnAttribute(Typeis not supported)Select,Where,OrderBy,OrderByDescending,ThenBy,ThenByDescending.Select<T>: You need to return withnew { ... }expression. Returning a scalar is not supported.!(NOT)String.ToUpper) are not supported.