c# - "Fluent methods may not be invoked on a Query created via CloudTable.CreateQuery<T>()" exception -


what following exception means?

system.notsupportedexception unhandled message: unhandled exception of type 'system.notsupportedexception' occurred in mscorlib.dll additional information: fluent methods may not invoked on query created via cloudtable.createquery()

it not show code throwing exception don't know how start debugging it.

 result stacktrace:       @ system.web.http.apicontroller.d__1.movenext()  --- end of inner exception stack trace ---     @ system.threading.tasks.task.throwifexceptional(boolean includetaskcanceledexceptions)     @ system.threading.tasks.task`1.getresultcore(boolean waitcompletionnotification)     @ system.threading.tasks.task`1.get_result()     @ testframework.executerequest(httprequestmessage request) in d:\     @ testframework.post(string uri, object tniobject) in d:\     @ testframework.postcall(string uri, object o) in d:\     @ testframework.mymethod(string one, string two, mystruct three) in d:\     ... (removed privacy)    

i believe problem in following instruction.

string querystring = tablequery.combinefilters(tablequery.generatefiltercondition("partitionkey", querycomparisons.equal, myid),                                                tableoperators.and,                                                tablequery.generatefiltercondition("rowkey", querycomparisons.equal, number)); var thequery = mytable.createquery<myentity>().where(querystring); 

can use thequery perform segmented async query?

var returnlist = new list<t>(); tablequerysegment<t> querysegment = null;  querysegment = await thequery.astablequery().executesegmentedasync(null);  // query potentially return more 1 object returnlist.addrange(querysegment); 

well, changing createquery method call following code made exception go away.

 var query = new tablequery<tenanttnentity>().where(querystring); 

the exception says:

 result message:  test method mymethod threw exception:  system.aggregateexception: 1 or more errors occurred. ---> system.invalidoperationexception: unknown table. tablequery not have associated cloudtable reference. please execute query via cloudtable executequery apis. 

i don't know if problem, mine, , took me while figure out. reasons i'm not entirely clear on, azure team has provided 2 different , incompatible ways execute queries - , although they're incompatible @ runtime, azure team has helpfully (not!) made sure have compatible signatures @ compile time.

see difference between "fluent" , "iqueryable" modes described here:

http://blogs.msdn.com/b/windowsazurestorage/archive/2013/09/07/announcing-storage-client-library-2-1-rtm.aspx

in other words, both of these compile , run , more or less same thing:

var fluentquery = new tablequery<t>().where(filter); var fluentresult = table.executequery(fluentquery);  var iqueryablequery= ent in table.createquery<t>()                       ent.partitionkey == "some value"                       select ent; var iqueryableresult = iqueryablequery.astablequery().execute(); 

but while 1 compile fine, blow @ runtime system.notsupportedexception (and i) ran into.

var fluentquery2 = table.createquery<t>().where(filter); var fluentresult2 = fluentquery2.execute(); 

i'm sure folks @ ms had reason particular violation of principle of least astonishment - they're not idiots - remains case behavior is, shall say, unusual.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -