title: unable to get result showing Object reference not set to an instance of an object
body: <p>i want get last record of table with particular column value. after that i need to increment value ..here table is empty and column propery is string </p>
  
  <pre><code>     public async Task&lt;string&gt; GetLastBillNo()
              {
                  return this.DbSet.LastOrDefault().CustomOrderNumber;
              } // getting Object reference not set to an instance of an object”
  </code></pre>
  
  <p>bs logic is </p>
  
  <pre><code> long billNo = 0;
  
       if (!string.IsNullOrEmpty(await invoiceRepository.GetLastBillNo()))
                      {
                          billNo = long.Parse(await invoiceRepository.GetLastBillNo());
                          billNo = billNo + 1;
                          order.CustomOrderNumber = billNo.ToString();
                      }
                      else
                          order.CustomOrderNumber = (billNo + 1).ToString();
  </code></pre>