Linq To SQL caching VS multi-user application - linq

We develop Win32 application that access to SQL 2005 database through Linq to SQL. The issue is when 2 users access to same record (View and Edit)… User 1 update record (DataContext.SubmitChanges()), User 2 will continue to see old information until he restart application. So, we would like to update context of user 2… The solution that appears right now is to call DataContext.Refresh to sync object with SQL table… We wondering if other solution exist ?
Thank you

I've noticed that Refresh can be really nasty depending on the data you've already grabbed from an entity, another solution is to reset the context you are using to a new instance.
context = new MyDataContext(ConnectionString);
This, at least in the scenarios where I am using it is less overhead and less DB calls.

Related

How to clear OBIEE cursor cache (presentation server)

I'm having an issue with a prompt in OBIEE 10g, such that it displays old database value due to the prompt query being serviced from cursor cache (presentation service). For example, if the prompt drop-down shows 1 value initially since there is 1 database row and when i delete this row from database, the prompt still shows the same database value unless i manually delete the cursor cache through analytics
Setting > Administration > Manage sessions > clear cache/cursors
Tried checking OBIEE presentation service config file instanceconfig.xml, however there is no such parameter to permanently disable this cache. I referenced the following link, OBIEE 10G/11G - Presentation Service (Query|Result|Cursor) Cache
Resetting these parameters didn't seem to have any impact on the cursor cache, these are still getting generated and are not cleared after the timeouts set. (I have restarted the OBIEE services after changing these parameters). Am I missing something here.
Would appreciate any pointers to get this done i.e. getting cursor cache cleared/disabled without manual intervention as mentioned above (through Settings > Administration).
At some point I also faced that issue. The presentation cache in OBIEE is a bit shady sometimes.
What I did is to add some dummy comparison on the query of the prompt, involving sysdate with enough precision so it makes each query different to the cache.
It's a bit shabby, but at least you don't need any manual intervention... Maybe it can help you.
Good luck!
You may see this issue if using a Presentation variable as well, rather than a Prompt built using a SQL query.
The problem may be due to shared Presentation Services Query Cache, which means
that even when the user logs out, the query cursor cache is still being shared by other users, so it does not refresh the new data after the user logs in again.
The cache file is in
ORACLE_INSTANCE/tmp/OracleBIPresentationServices/coreapplication_obipsn/obis_temp
See this document for more detail.
You can configure the Virtual Private Database option in the repository
physical database object and mark session variables as Security Sensitive in
the repository to make the query cache not shared among users. See this
documentation for more detail.

How to find sql query in weblogic

I support an application whose UI is built on weblogic server. I need to know the sql query fired in the database whenever any action is performed on UI. Since there a lot of users hence I need to know is there any specific action through which I can identify it ?
Your managed server logs should give you queries run through a PreparedStatement. Any database will give you auditing capabilities so you can track what SQL was run, origins and parameters passed.

Linq DataContext.CreateDatabase on Azure

This came up once before: Use DataContext.CreateDatabase in SQL Azure
The answer accepted was "maybe it's not possible". Didn't seem like a full answer.
I have a set of classes fully defined and I am wanting to create a database on Azure for this. It's not working because the USE statement does not work: http://msdn.microsoft.com/en-us/library/azure/ee336288.aspx
So, the database gets created as blank, and internally Linq generates a USE statement to move to that database and start adding tables. This fails and it throws an exception.
So how can I create my database? Can I use Linq to add tables to an existing database? Can I enable USE on Azure somehow? Seems ridiculous this does not work.
After messing around for a while on this, I ended up creating the database against a local SQL Server instance. Then used SQL Server Management Studio -> Tasks -> Script Database, and turned on the export type to be Microsoft Azure. Then I had the script file needed to run on the Azure server. I'll leave the question open for a day or two because I am curious if this can work with Azure directly somehow. If I don't hear anything, I will close it.
The USE statement does not switch between databases in Azure SQL Database. You will have to connect to the database to create a table on that database.
Regards
Dhruv

How can I debug the SQL generated by EF5 during runtime?

So I am pretty new to EntityFramework, actualy in the POC stage right now, and one of the questions I am trying to answer is how can I visualize the query generated by EF through the debugger or other process attachable tool?
The case I am trying to solve is while trying to debug a QA, or production issue, the developer needs to be able to attach to the process through the remote debugger, and needs to visualize the query created by EF to see if it's framed in the most effective manner.
The same can be said during development, where I need to be able to visualize the query made by EF.
You can either:
Use Sql Server Management Studio Query Analyzer to see the traffic that goes to the database (probably the least invasive)
Attach VS to your process and use IntelliTrace is should show commands sent to the database
Try using EF Tracing provider (http://code.msdn.microsoft.com/EFProviderWrappers)
For queries you can do .ToTraceString() on ObjectQuery object and .ToString() on DbQuery object when debugging.
EDIT
EF6 contains a new feature that allows you log the traffic to the database

Linq to Sql Update not working

I have somewhere around 20 tables that I am working with. I can update the User table just fine, however, when I try to update my Address table, nothing happens. I don't receive an exception and the method looks like it executes ok but when I check my data, the values are still the same.
I'm thinking that it has to do with the fact that I moved my database out from under a server and onto my local SQL lite instance. I did change the connection strings in the config and thought that it would take care of the problem (as i stated, I can still select from all of the tables using linq). Has anyone encountered this before or have some idea of what might be going on?
Edit 1 - I'm not very familiar with relocating databases with linq. I do know that SQLMETAL, when I run it, removes all of the customization that i have done inside of my datacatalog. Does just changing the connection in the config work or do I actually have to use SQLMETAL every time the db moves (the structure doesn't change)
When I did this I had to hand modify the constructor to use a different connection string in the File that Visual Studio generates for your instance of the database. I had the same issue as you did and this fixed the problem for me.

Resources