Skip to main content
replaced http://stackapps.com/ with https://stackapps.com/
Source Link
added 1444 characters in body
Source Link
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60

###Update:

So it was written, so it is done.

Go see the real deal!

var questionWithStuff =
    ctx // soapi context
    .Official // convenience properties for known sites
    .StackOverflow
    .Questions
    .Tagged("asp.net","c#")
    .FromDate("january 1, 2001")
    .ToDate(new DateTime(2020, 10, 10))
    .WithBody
    .WithAnswers
    .WithComments
    .Page(1)
    .PageSize(2)
    .Pages(3)
    .Sort(QuestionSort.Votes)
    .Min(1)
    .Max(100)
    .Order(SortOrder.Asc)
    .ToList();

Assert.AreEqual(6, questionWithStuff.Count);

// issues the following requests

// http://api.stackoverflow.com/1.0/questions?answers=true&body=true&comments=true&fromdate=978307200&max=100&min=1&order=Asc&page=1&pagesize=2&sort=Votes&tagged=asp.net%3bc%23&todate=1602288000
// http://api.stackoverflow.com/1.0/questions?answers=true&body=true&comments=true&fromdate=978307200&max=100&min=1&order=Asc&page=2&pagesize=2&sort=Votes&tagged=asp.net%3bc%23&todate=1602288000
// http://api.stackoverflow.com/1.0/questions?answers=true&body=true&comments=true&fromdate=978307200&max=100&min=1&order=Asc&page=3&pagesize=2&sort=Votes&tagged=asp.net%3bc%23&todate=1602288000

The question is, would anyone be interested in using code that looks like this? Just like this and does what it says it will do?

The question is, would anyone be interested in using code that looks like this? Just like this and does what it says it will do?

###Update:

So it was written, so it is done.

Go see the real deal!

var questionWithStuff =
    ctx // soapi context
    .Official // convenience properties for known sites
    .StackOverflow
    .Questions
    .Tagged("asp.net","c#")
    .FromDate("january 1, 2001")
    .ToDate(new DateTime(2020, 10, 10))
    .WithBody
    .WithAnswers
    .WithComments
    .Page(1)
    .PageSize(2)
    .Pages(3)
    .Sort(QuestionSort.Votes)
    .Min(1)
    .Max(100)
    .Order(SortOrder.Asc)
    .ToList();

Assert.AreEqual(6, questionWithStuff.Count);

// issues the following requests

// http://api.stackoverflow.com/1.0/questions?answers=true&body=true&comments=true&fromdate=978307200&max=100&min=1&order=Asc&page=1&pagesize=2&sort=Votes&tagged=asp.net%3bc%23&todate=1602288000
// http://api.stackoverflow.com/1.0/questions?answers=true&body=true&comments=true&fromdate=978307200&max=100&min=1&order=Asc&page=2&pagesize=2&sort=Votes&tagged=asp.net%3bc%23&todate=1602288000
// http://api.stackoverflow.com/1.0/questions?answers=true&body=true&comments=true&fromdate=978307200&max=100&min=1&order=Asc&page=3&pagesize=2&sort=Votes&tagged=asp.net%3bc%23&todate=1602288000

The question is, would anyone be interested in using code that looks like this? Just like this and does what it says it will do?

added 247 characters in body
Source Link
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60
 

And this is without LINQ. When/if I accept the task and finish implementing this, Dave and I have been talking about merging this with StackLINQ to provide the kindStatus

The lazy loading proof of client library that will letconcept is working just as you stop worrying about how to get datasee above and let you concentrate on doing something interesting with itwill be ready for release in a few days.

// real live linq

var someInterstingQuestions = ctx.Sites("api.stackoverflow.com")
.Users.Where(u=>u.Reputation > 20000)
.Questions.Where(q=>(q.Title.Contains("foo") || 
q.Title.Contains("bar")) && q.UpVotes > 10).Skip(5).Take(10);

// the Skip is a multiple of the take, so get the 6th page of 10

//

Can we get some pre-orders please?The idea of layering a LINQ provider on top of this is on hold. See Luke's answer.


And this is without LINQ. When/if I accept the task and finish implementing this, Dave and I have been talking about merging this with StackLINQ to provide the kind of client library that will let you stop worrying about how to get data and let you concentrate on doing something interesting with it.
// real live linq

var someInterstingQuestions = ctx.Sites("api.stackoverflow.com")
.Users.Where(u=>u.Reputation > 20000)
.Questions.Where(q=>(q.Title.Contains("foo") || 
q.Title.Contains("bar")) && q.UpVotes > 10).Skip(5).Take(10);

// the Skip is a multiple of the take, so get the 6th page of 10

//

Can we get some pre-orders please?

And this is without LINQ. When/if I accept the task and finish implementing this, Dave and I have been talking about merging this with StackLINQ to provide the kind of client library that will let you stop worrying about how to get data and let you concentrate on doing something interesting with it.

// real live linq

var someInterstingQuestions = ctx.Sites("api.stackoverflow.com")
.Users.Where(u=>u.Reputation > 20000)
.Questions.Where(q=>(q.Title.Contains("foo") || 
q.Title.Contains("bar")) && q.UpVotes > 10).Skip(5).Take(10);

// the Skip is a multiple of the take, so get the 6th page of 10

//

Can we get some pre-orders please?

 

Status

The lazy loading proof of concept is working just as you see above and will be ready for release in a few days.

The idea of layering a LINQ provider on top of this is on hold. See Luke's answer.


And this is without LINQ. When/if I accept the task and finish implementing this, Dave and I have been talking about merging this with StackLINQ to provide the kind of client library that will let you stop worrying about how to get data and let you concentrate on doing something interesting with it.
// real live linq

var someInterstingQuestions = ctx.Sites("api.stackoverflow.com")
.Users.Where(u=>u.Reputation > 20000)
.Questions.Where(q=>(q.Title.Contains("foo") || 
q.Title.Contains("bar")) && q.UpVotes > 10).Skip(5).Take(10);

// the Skip is a multiple of the take, so get the 6th page of 10

//

Can we get some pre-orders please?

not a library announcement, and no need to make a new tag for this...
Link
Kevin Montrose
  • 18.7k
  • 6
  • 35
  • 62
Loading
added 4 characters in body
Source Link
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60
Loading
added 261 characters in body; added 43 characters in body; added 92 characters in body
Source Link
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60
Loading
added 552 characters in body
Source Link
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60
Loading
Source Link
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60
Loading