title: Awaitable Properties in C#
body: <p>In C#, does it violate best-practices to have Properties of type <code>Task</code>, which allow you to <code>await</code> the Property?</p>
  <p>I verified that the C# compiler allows this code, but I'm curious if this is violates best-practices?</p>
  <p>Below is an example showing how to implement an awaitable Property to retrive a SQLite database.</p>
  <h1>Sample Code</h1>
  <h3>Consuming the awaitable Property in Parent Class</h3>
  <pre><code>public class Database : BaseDatabase
  {
      ...
  
      async Task&lt;List&lt;MyModel&gt;&gt; GetAllData()
      {
          //**** Awaiting a Property ****//
          var databaseConnection = await DatabaseConnectionTask;
  
          databaseConnection.Table&lt;MyModel&gt;().ToListAsync();
      }
  
      ...
  }
  </code></pre>
  <h3>Creating the awaitable Property in Base Class</h3>
  <pre><code>public abstract class BaseDatabase
  {
      readonly SQLiteAsyncConnection _databaseConnection = new SQLiteAsyncConnection(path);
  
      bool _isInitialized;
  
      //**** Awaitable Property ****//
      protected Task&lt;SQLiteAsyncConnection&gt; DatabaseConnectionTask =&gt; GetDatabaseConnection();
  
      static async Task&lt;SQLiteAsyncConnection&gt; GetDatabaseConnection()
      {
          if (!_isInitialized)
              await Initialize();
  
          return _databaseConnection;
      }
  
      static async Task Initialize()
      {
          await _databaseConnection.CreateTableAsync&lt;MyModel&gt;();
          _isInitialized = true;
      }
  }
  </code></pre>