How do I trace a linq query when using PredicateBuilder/AsExpandable? - linq

I am using PredicateBuilder, which means that I am using the AsExpandable extension method. The problem is that I can no longer Trace my SQL queries as the following error is thrown when I try to cast the query to ObjectQuery so that I can do a ObjectQuery.ToTraceString() call on it...
Unable to cast object of type 'LinqKit.ExpandableQuery`1[Genesis.Person]' to type 'System.Data.Objects.ObjectQuery'.
Any Ideas?

I would recommend running a Dump() on your query in LINQPad, and using the SQL tab to see what SQL was generated. Do do this, hook up LINQPad to your Entity Framework context, press F4 to include a reference to LinqKit.dll, and LinqKit as a namespace import. Let me know if you need additional guidance in how to do this.

Use the following universal PredicateBuilder instead of LinqKit:
http://petemontgomery.wordpress.com/2011/02/10/a-universal-predicatebuilder/
Then ObjectQuery.ToTraceString() will work as expected.

I'm not familiar with your precise problem but can you not run the trace on the SQL server instead using (eg profiler assuming MSSQL) ?
This would still allow you to see the executed queries and you could restrict it to be just your machine that is recorded...

Related

How do I debug work of 2sxc if Visual Query works perfectly during debug, but cshtml code can't access data?

I've edited some existing visual queries of Blog 4.0 application and when I was debugging it - it worked perfectly. But then on page it stopped working. Any attempt to use key with Data like Data["Posts"] raises System.Collections.Generic.KeyNotFoundException. App.Query["Blog Posts List"]["Posts"] returns something, but any attempt to access its fields raises another exception (don't remember the name, but it said that there's no such member inside that object).
I didn't rename queries, I didn't change application settings. I just edited logic of 2 queries. I renamed 1 wiring endpoint name across 3 queries in whole chain.
How do I debug it? How can I see what does cshtml receive from database so I don't guess and put my crystal ball away?
In general, App.Query["Name of Query"] will get you the streams of data. You usually need to convert it using AsDynamic() or AsList() to something you can work with.
This should help some; What is Data?
If you're just running into problems with field names, you probably forgot the AsList or AsDynamic, just like #accuraty-jeremy mentioned.
For real debugging, go to insights, you'll see what happens - but in your case it probably won't help, because your working with an object that's not dynamic (so doesn't support .FirstName) until you AsList/AsDynamic it.
My bad: I confused two different files - _List.cshtml and _List Paging.cshtml. So I was searching for an error in the code of wrong file.

Debug query while executing in Preview Mode SSRS

My goal is to view the query that gets executed against the server while in Preview Mode of reporting services.
Is there anyway to do this? Or another approach that I can take to debug the actual query that is being executed by my SSRS report?
I can attach the query text, however I'm more concerned that the parameters are being passed correctly to the query.
I would suggest to install
ExpressProfiler
This is what I used to check that parameters are being passed correctly or not. Try this!

Cognos session parameters usage

I have setup LDAP authentication and set up "custom properties" in cognos configuration to get a attribute i have defined in the LDAP entry.
For example this custom property is called ORG_NAME, how do i use this ORG_NAME in report studio as a parameter to filter on? I have seen online about mapping with Framework manager.. however the particular reports i am using access the database directly and DO NOT have a framework manager package associated with them, so i need to use the ORG_NAME without using FM....
You can use the same syntax you would use in FM. So, for example:
#sq($account.personalInfo.givenName)#
will return the first name, and so on.
If you feel some burning need to for user-written SQL, instead of using FM, you can include the macro as a query item in your "outer" query (that gets the results from your sql query, Query2 in the image below).

populate a formview using linq - vs2010 c#

Using Linq I have built a query which I return to a gridview.
This works fine but I want to populate a formview with the same data,
can anyone point me to a decent how-to article please?
thanks
Try to assign your query result to a DataSource property, then try to execute DataBind() method.. it should work.. if not, please provide us some code...
Regards..

Filtering Asynchronous OData Queries on Windows Phone 7

I am working on an application for Windows Phone 7 that makes asynchronous queries to OData. I use the following general form for the query:
DataServiceQuery<Entity> query = ourEntities.CreateQuery<Entity>("Entities");
entities.BeginExecute(QueryComplete, query);
I am having trouble adding filters to these queries, though. Using LINQ did not seem to be an option for asynchronous queries, so I tried adding OData filters using the AddQueryOption method mentioned in this article (trying to get results for when the Id is 1):
query.AddQueryOption("$filter", "Id eq 1");
If we take the URL from the async result and paste it into a browser, it works properly and returns the expected result. However, attempting to evaluate the result of the query always seems to result in a NotSupportedException with no message or inner stack trace.
Ideally, I'd like to be able to use LINQ, like Scott Hanselman did in his blog post about OData. If that is not an option for asynchronous data retrieval, how can I achieve filtering on the query?
Currently the LINQ support on the Windows Phone 7 platform is limitted. The previous WCF Data Services client was meant to try what would work and what would not work for our users, but it has its limitations. See this blog post for more details: http://blogs.msdn.com/b/astoriateam/archive/2010/09/27/wcf-data-services-client-library-and-windows-phone-7-next-steps.aspx
In general I would suggest you use the BeginExecute method instead and construct the URL manually without the use of DataServiceQuery class, which as noted in the above blog will not be available in the first official release.

Resources