Getting coordinates and storing in c# model using async [duplicate]












2
















This question already has an answer here:




  • How to call an async method from a getter or setter?

    9 answers




I am trying to get coordinates stored in the address model. I am using google maps api with the Chadly/Geocoding.net to get the coordinates but it requires async and I have never used async within a model and having problems getting it to work.



It is throwing me this error




"Cannot implicitly convert type 'Geocoding.Location' to 'System.Threading.Tasks.Task<Geocoding.Location>'"




Anything special I have to do to get this to work?



   public string FullAddress 
{
get
{
return Address + " " + City + " " + State + "" + ZipCode;
}
}
public async Task<Geocoding.Location> Coordinates
{
get
{
IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);

return addresses.First().Coordinates;
}

}









share|improve this question















marked as duplicate by Steve .net
Users with the  .net badge can single-handedly close .net questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 25 '18 at 23:29


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • What are the problems? Any errors?

    – Nkosi
    Nov 25 '18 at 23:20













  • Hey Nkosi I updated with my error I am receiving.

    – dbollig
    Nov 25 '18 at 23:23






  • 1





    I suggest that you don't call async methods from a property getter. Make them a method. Also, please provide a Minimal, Complete, and Verifiable example because we simply can not tell what you actually need just from the code that you provided

    – Dennis Kuypers
    Nov 25 '18 at 23:25











  • Coordinates should be a method. you can't have async properties

    – Nkosi
    Nov 25 '18 at 23:27
















2
















This question already has an answer here:




  • How to call an async method from a getter or setter?

    9 answers




I am trying to get coordinates stored in the address model. I am using google maps api with the Chadly/Geocoding.net to get the coordinates but it requires async and I have never used async within a model and having problems getting it to work.



It is throwing me this error




"Cannot implicitly convert type 'Geocoding.Location' to 'System.Threading.Tasks.Task<Geocoding.Location>'"




Anything special I have to do to get this to work?



   public string FullAddress 
{
get
{
return Address + " " + City + " " + State + "" + ZipCode;
}
}
public async Task<Geocoding.Location> Coordinates
{
get
{
IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);

return addresses.First().Coordinates;
}

}









share|improve this question















marked as duplicate by Steve .net
Users with the  .net badge can single-handedly close .net questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 25 '18 at 23:29


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • What are the problems? Any errors?

    – Nkosi
    Nov 25 '18 at 23:20













  • Hey Nkosi I updated with my error I am receiving.

    – dbollig
    Nov 25 '18 at 23:23






  • 1





    I suggest that you don't call async methods from a property getter. Make them a method. Also, please provide a Minimal, Complete, and Verifiable example because we simply can not tell what you actually need just from the code that you provided

    – Dennis Kuypers
    Nov 25 '18 at 23:25











  • Coordinates should be a method. you can't have async properties

    – Nkosi
    Nov 25 '18 at 23:27














2












2








2


1







This question already has an answer here:




  • How to call an async method from a getter or setter?

    9 answers




I am trying to get coordinates stored in the address model. I am using google maps api with the Chadly/Geocoding.net to get the coordinates but it requires async and I have never used async within a model and having problems getting it to work.



It is throwing me this error




"Cannot implicitly convert type 'Geocoding.Location' to 'System.Threading.Tasks.Task<Geocoding.Location>'"




Anything special I have to do to get this to work?



   public string FullAddress 
{
get
{
return Address + " " + City + " " + State + "" + ZipCode;
}
}
public async Task<Geocoding.Location> Coordinates
{
get
{
IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);

return addresses.First().Coordinates;
}

}









share|improve this question

















This question already has an answer here:




  • How to call an async method from a getter or setter?

    9 answers




I am trying to get coordinates stored in the address model. I am using google maps api with the Chadly/Geocoding.net to get the coordinates but it requires async and I have never used async within a model and having problems getting it to work.



It is throwing me this error




"Cannot implicitly convert type 'Geocoding.Location' to 'System.Threading.Tasks.Task<Geocoding.Location>'"




Anything special I have to do to get this to work?



   public string FullAddress 
{
get
{
return Address + " " + City + " " + State + "" + ZipCode;
}
}
public async Task<Geocoding.Location> Coordinates
{
get
{
IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);

return addresses.First().Coordinates;
}

}




This question already has an answer here:




  • How to call an async method from a getter or setter?

    9 answers








c# .net






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 23:23









Nkosi

114k16125192




114k16125192










asked Nov 25 '18 at 23:19









dbolligdbollig

413




413




marked as duplicate by Steve .net
Users with the  .net badge can single-handedly close .net questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 25 '18 at 23:29


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Steve .net
Users with the  .net badge can single-handedly close .net questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 25 '18 at 23:29


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • What are the problems? Any errors?

    – Nkosi
    Nov 25 '18 at 23:20













  • Hey Nkosi I updated with my error I am receiving.

    – dbollig
    Nov 25 '18 at 23:23






  • 1





    I suggest that you don't call async methods from a property getter. Make them a method. Also, please provide a Minimal, Complete, and Verifiable example because we simply can not tell what you actually need just from the code that you provided

    – Dennis Kuypers
    Nov 25 '18 at 23:25











  • Coordinates should be a method. you can't have async properties

    – Nkosi
    Nov 25 '18 at 23:27



















  • What are the problems? Any errors?

    – Nkosi
    Nov 25 '18 at 23:20













  • Hey Nkosi I updated with my error I am receiving.

    – dbollig
    Nov 25 '18 at 23:23






  • 1





    I suggest that you don't call async methods from a property getter. Make them a method. Also, please provide a Minimal, Complete, and Verifiable example because we simply can not tell what you actually need just from the code that you provided

    – Dennis Kuypers
    Nov 25 '18 at 23:25











  • Coordinates should be a method. you can't have async properties

    – Nkosi
    Nov 25 '18 at 23:27

















What are the problems? Any errors?

– Nkosi
Nov 25 '18 at 23:20







What are the problems? Any errors?

– Nkosi
Nov 25 '18 at 23:20















Hey Nkosi I updated with my error I am receiving.

– dbollig
Nov 25 '18 at 23:23





Hey Nkosi I updated with my error I am receiving.

– dbollig
Nov 25 '18 at 23:23




1




1





I suggest that you don't call async methods from a property getter. Make them a method. Also, please provide a Minimal, Complete, and Verifiable example because we simply can not tell what you actually need just from the code that you provided

– Dennis Kuypers
Nov 25 '18 at 23:25





I suggest that you don't call async methods from a property getter. Make them a method. Also, please provide a Minimal, Complete, and Verifiable example because we simply can not tell what you actually need just from the code that you provided

– Dennis Kuypers
Nov 25 '18 at 23:25













Coordinates should be a method. you can't have async properties

– Nkosi
Nov 25 '18 at 23:27





Coordinates should be a method. you can't have async properties

– Nkosi
Nov 25 '18 at 23:27












2 Answers
2






active

oldest

votes


















2














Coordinates should be refactored to a method. You can't have async properties



public async Task<Geocoding.Location> GetCoordinates(){
IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);
return addresses.First().Coordinates;
}





share|improve this answer































    0














    unfortunately, you cannot use an async property getter in C#.



    Just turn it to a method instead, and it will work fine.



    public async Task<Geocoding.Location> GetCoordinates()
    {
    IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);

    return addresses.First().Coordinates;
    }





    share|improve this answer






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      Coordinates should be refactored to a method. You can't have async properties



      public async Task<Geocoding.Location> GetCoordinates(){
      IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);
      return addresses.First().Coordinates;
      }





      share|improve this answer




























        2














        Coordinates should be refactored to a method. You can't have async properties



        public async Task<Geocoding.Location> GetCoordinates(){
        IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);
        return addresses.First().Coordinates;
        }





        share|improve this answer


























          2












          2








          2







          Coordinates should be refactored to a method. You can't have async properties



          public async Task<Geocoding.Location> GetCoordinates(){
          IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);
          return addresses.First().Coordinates;
          }





          share|improve this answer













          Coordinates should be refactored to a method. You can't have async properties



          public async Task<Geocoding.Location> GetCoordinates(){
          IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);
          return addresses.First().Coordinates;
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 23:28









          NkosiNkosi

          114k16125192




          114k16125192

























              0














              unfortunately, you cannot use an async property getter in C#.



              Just turn it to a method instead, and it will work fine.



              public async Task<Geocoding.Location> GetCoordinates()
              {
              IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);

              return addresses.First().Coordinates;
              }





              share|improve this answer




























                0














                unfortunately, you cannot use an async property getter in C#.



                Just turn it to a method instead, and it will work fine.



                public async Task<Geocoding.Location> GetCoordinates()
                {
                IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);

                return addresses.First().Coordinates;
                }





                share|improve this answer


























                  0












                  0








                  0







                  unfortunately, you cannot use an async property getter in C#.



                  Just turn it to a method instead, and it will work fine.



                  public async Task<Geocoding.Location> GetCoordinates()
                  {
                  IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);

                  return addresses.First().Coordinates;
                  }





                  share|improve this answer













                  unfortunately, you cannot use an async property getter in C#.



                  Just turn it to a method instead, and it will work fine.



                  public async Task<Geocoding.Location> GetCoordinates()
                  {
                  IEnumerable<Address> addresses = await geocoder.GeocodeAsync(FullAddress);

                  return addresses.First().Coordinates;
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 25 '18 at 23:29









                  Pac0Pac0

                  7,86622745




                  7,86622745















                      Popular posts from this blog

                      Lallio

                      Futebolista

                      Jornalista