Fluent Interface is an advanced API design that really on extension methods and methods chaining. When of the most famous examples of fluent API is the linq extension methods for IEnumerable.

var passed=Students.Where(s=>s.Passed).Select(s=>s.Name).ToList();

In the asynchronous Programming, async/await, fluent APIs are kind of limited due to the nature of the Task object that it is hot build default, in this article, we will overcome this problem and will build a small library that allows fluent extension methods.

as an example,

var data=await GetDataAsync()

.AsRepeatable(TimeSpan.FromSeconds(10))

.FirstOrDefaultAsync(data=>data.Any());

another example could be

var data=await GetNewsAsync()

.Where(newsList=>newsList.Date>=DateTime.Today)

.SelectMany(newsList=>newsList.NewsItems)

.ToList();

Just to give you an idea of how this code could be written using Imperative approach

var newsList=await GetNewsAsync();

if(newsList.Date>=DateTime.Today)

{

return newsList.Select(news=>news.NewsItems).ToList();

}

else

return new List<NewsItem>();

It is up to you to choose which code fashion you would like, if you like the second one, you can stop reading this article as in the rest of the article we will extend the c sharp language to make the first one applicable.