Getting coordinates and storing in c# model using async [duplicate]
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;
}
}
c# .net
marked as duplicate by Steve
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.
add a comment |
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;
}
}
c# .net
marked as duplicate by Steve
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
Coordinatesshould be a method. you can't have async properties
– Nkosi
Nov 25 '18 at 23:27
add a comment |
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;
}
}
c# .net
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
c# .net
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
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
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
Coordinatesshould be a method. you can't have async properties
– Nkosi
Nov 25 '18 at 23:27
add a comment |
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
Coordinatesshould 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
add a comment |
2 Answers
2
active
oldest
votes
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;
}
add a comment |
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;
}
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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;
}
add a comment |
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;
}
add a comment |
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;
}
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;
}
answered Nov 25 '18 at 23:28
NkosiNkosi
114k16125192
114k16125192
add a comment |
add a comment |
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;
}
add a comment |
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;
}
add a comment |
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;
}
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;
}
answered Nov 25 '18 at 23:29
Pac0Pac0
7,86622745
7,86622745
add a comment |
add a comment |
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
Coordinatesshould be a method. you can't have async properties– Nkosi
Nov 25 '18 at 23:27