c# - Error converting query to string -


im having issue converting query string...i did research , found majority of answers attach first or single end of query, can seen.i thought might of been cache problem cleaned solution. in error below

error 1 cannot implicitly convert type 'jobtracker.models.location' 'string'

code in question:

public static string clientipname() {     string clientip = null;     clientip = httpcontext.current.request.userhostaddress;     return clientip; }  public static string locationipassign() {     jobdata db = new jobdata();      var workstationlocation = clientipname();     var result = db.locations         .where(l => l.assignedip == workstationlocation)         .firstordefault();      return result; } 

initial error:

cannot implicitly convert type system.linq.iqueryable string

any ideas causing error?

your firstordefault call resulting in location object , want string. guess 1 of properties on location you're trying return, select value off.

var result = db.locations     .where(l => l.assignedip == workstationlocation)     .select(l => l.<whatever string property want>)     .firstordefault(); 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -