This question is locked. New answers and comments are not allowed.
Dennis Gundersen
Top achievements
Rank 1
Dennis Gundersen
asked on 05 Mar 2010, 02:44 PM
Hi
I have a solution with three projects, Entities, WebApp and WinApp. I found a video that shows how to implement syncronization using a local database cache and it looked really easy (doesn't it always ;-), but I can't figure out how to use OA with this.
Is there an easy way to change the connection in Entities back and forth so that it gets data from the local sdf file for the WinApp if there's not network available, and from the SQL server for the WebApp? I'd prefer not to have two different solutions with copies of the Entities project as they're bound to become unsynced.
TIA!
Re
Dennis
I have a solution with three projects, Entities, WebApp and WinApp. I found a video that shows how to implement syncronization using a local database cache and it looked really easy (doesn't it always ;-), but I can't figure out how to use OA with this.
Is there an easy way to change the connection in Entities back and forth so that it gets data from the local sdf file for the WinApp if there's not network available, and from the SQL server for the WebApp? I'd prefer not to have two different solutions with copies of the Entities project as they're bound to become unsynced.
TIA!
Re
Dennis
6 Answers, 1 is accepted
0
Accepted
IT-Als
Top achievements
Rank 1
answered on 05 Mar 2010, 03:38 PM
Hi Dennis,
I am not sure if I understand your question/architecture correctly, but one way to achieve it could be to modify the scope provider (the one that creates the ObjectScope instance for you, and thus the Database instance, too).. The idea is to have two connection ids which can switch at runtime depending on if you're online or not.
I think I have seen a sample of how this is done on the Telerik site
Regards
Henrik
I am not sure if I understand your question/architecture correctly, but one way to achieve it could be to modify the scope provider (the one that creates the ObjectScope instance for you, and thus the Database instance, too).. The idea is to have two connection ids which can switch at runtime depending on if you're online or not.
I think I have seen a sample of how this is done on the Telerik site
Regards
Henrik
0
Dennis Gundersen
Top achievements
Rank 1
answered on 05 Mar 2010, 03:54 PM
As I understand it, your suggestion is to create two connection strings and then basically check "if online then use id1, else use id2". That's clever, and I believe I've seen a Telerik video on that. Maybe it can be combined with some compilation directives so the WinApp is offline by default.
I've also found that part of my problem is that the synch wizard added two date fields to the sdf that is missing in the mdf.
Thanks.
Re
Dennis
I've also found that part of my problem is that the synch wizard added two date fields to the sdf that is missing in the mdf.
Thanks.
Re
Dennis
0
IT-Als
Top achievements
Rank 1
answered on 06 Mar 2010, 09:46 AM
Yes,
That's is exactly what I am suggesting. See if it suits your needs.
We have a scenario like that in our WCF based solution and smart client front end. The Smart Client caches commonly used data contracts (from the WCF services, for example: country codes, currency codes, etc..).. When the Smart Client needs information it talks to a Service Agent... This service agent has logic built-in on how to deal with the cache or go to the WCF service to get a fresh set of information if the cache is out-dated.. I think this concept can easily be transitioned to handle online-offline capabilities, too..
Regards
Henrik
That's is exactly what I am suggesting. See if it suits your needs.
We have a scenario like that in our WCF based solution and smart client front end. The Smart Client caches commonly used data contracts (from the WCF services, for example: country codes, currency codes, etc..).. When the Smart Client needs information it talks to a Service Agent... This service agent has logic built-in on how to deal with the cache or go to the WCF service to get a fresh set of information if the cache is out-dated.. I think this concept can easily be transitioned to handle online-offline capabilities, too..
Regards
Henrik
0
Dennis Gundersen
Top achievements
Rank 1
answered on 06 Mar 2010, 03:59 PM
Hi
I found a video that shows how to change connection strings at both runtime and compile time through properties. It's not Telerik, so I'll include the link below.
http://windowsclient.net/learn/video.aspx?v=13409
Re
Dennis
I found a video that shows how to change connection strings at both runtime and compile time through properties. It's not Telerik, so I'll include the link below.
http://windowsclient.net/learn/video.aspx?v=13409
Re
Dennis
0
Hi Dennis Gundersen,
As Henrik already said, you can have two connections defined and obtain the object scope based on the name of the connection that you need:
The configuration in the App.config would look similar to this:
Hope that helps.
Greetings,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
As Henrik already said, you can have two connections defined and obtain the object scope based on the name of the connection that you need:
IObjectScope scope =
null
;
if
(workOffline)
{
scope = Database.Get(
"DatabaseConnection1"
).GetObjectScope();
}
else
{
scope = Database.Get(
"DatabaseConnection2"
).GetObjectScope();
}
The configuration in the App.config would look similar to this:
<
openaccess
xmlns
=
"http://www.telerik.com/OpenAccess"
>
<
references
/>
<
connections
>
<
connection
id
=
"DatabaseConnection1"
>
<
connectionString
>Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True</
connectionString
>
<
backendconfigurationname
>mssqlConfiguration</
backendconfigurationname
>
</
connection
>
<
connection
id
=
"DatabaseConnection2"
>
<
connectionString
>Data Source=.\SQLEXPRESS;Initial Catalog=NorthwindOA;Integrated Security=True</
connectionString
>
<
backendconfigurationname
>mssqlConfiguration</
backendconfigurationname
>
</
connection
>
</
connections
>
<
backendconfigurations
>
<
backendconfiguration
id
=
"mssqlConfiguration"
backend
=
"mssql"
>
<
mappingname
>mssqlMapping</
mappingname
>
</
backendconfiguration
>
</
backendconfigurations
>
<
mappings
current
=
"mssqlMapping"
>
<
mapping
id
=
"mssqlMapping"
>
</
mapping
>
</
mappings
>
</
openaccess
>
Greetings,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
IT-Als
Top achievements
Rank 1
answered on 15 Mar 2010, 02:16 PM
Hi Alexander,
Thanks for supplying the example. Precise what I had in mind.
Regards
Henrik
Thanks for supplying the example. Precise what I had in mind.
Regards
Henrik