c# - Why does database query look like this? -


i want query database , show result. code:

[httpget] public actionresult index(string message) {     var result = client in db.clients                    clients.clientname == message                    select clients.clientname;      viewbag.message = result;      getcurrentuser();     return view(); } 

where message variable taken input element. want show using viewbag.message in view. on page see this:

select [extent1].[clientid] [clientid], [extent1].[clientname] [clientname] [dbo].[clients] [extent1] [extent1].[clientname] = @p__linq__0 

what mean?

the result variable contains linq query - not string. since imply want show 1 message, need first result - not query itself:

viewbag.message = result.firstordefault(); 

this, however, assumes want viewbag.message value of clientname database column (which in turn same message), suspect not want...

to answer original question:

what see result of calling tostring() on dbquery<t>, gives sql query used fetch data want.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -