This is a migrated thread and some comments may be shown as answers.
N-Tier Example like discribed in Todd Anglin's Blog
7 Answers 92 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alexander Becker
Top achievements
Rank 1
Alexander Becker asked on 21 Jan 2010, 10:21 PM
Hello,

I've just read the blog post of Todd Anglin describing how to use OA-ORM for N-Tier Designs.
Now I am looking for an example which implements these suggestions.
Is there any available? Especially sample implementations for the Data-Layer and the Business-Layer are of interest for me.
I would prefer a simple WindowsForms sample.

thanks
Alex.

7 Answers, 1 is accepted

Sort by
0
Chris Jansen
Top achievements
Rank 1
answered on 22 Jan 2010, 05:54 AM
Alex-

Have you seen the Northwind N-Tier Web Demo Application? It's not identical to Todd's design, but it is similar.

Chris
0
Alexander Becker
Top achievements
Rank 1
answered on 23 Jan 2010, 01:10 PM
Hello,

yes, i've seen this sample, but I think it is far away from Todds ideas.
I do not want to use a differnt object model for data-access and business-layer.
The way the datamodel is used in todds blog (vertical across all layers) seems to be very nice and simple to me.

I have difficulties to decide what sort of code to place inside the data layer.
Todd says all the Linq-stuff could be placed there, but I could learn much better from a sample.

Anyway.
I tried to put things together for my own now.
A simple solution containing four pojects: DomainModel, DataLayer, LogReader (=BusinessLayer) and TestApp (=Frontend).

  • DomainModel: containing a class RawLogEntry marked as Persistent
    Project is enabled for persistent classes and marked for enhancing (whatever this means...)
    Mapping is done forward to a SQL-Server 2005 express, it worked like a charm
  • DataLayer: containing the objectScopeProvider from the wizzard and a class RawLogEntryRepository to access the DB
    Project is enabled for DAL
  • LogReader: containing code to get and parse logstrings and to put them as RawLogEntries to the DB using the RawLogEntryRepository from the DataLayer
  • TestApp: simple starter console app

Unfortunately I cannot get this simple thing to work.
If I start it, I get a message saying The 'openaccess' section cannot be found in the application's configuration file. at Telerik.OpenAccess.Database.Get("DBConn")

If I enable the TestApp project (what I do not want anyway...) there comes another message up at db.GetObjectScope():
Telerik.OpenAccess: No enhanced assembly has been found for meta-data construction.
This may be caused by a missing app.config file (use app.config as embedded resource then)
or by an insufficient references section in the configuration file (add the referenced enhanced assemblies there too)
or by a wrong enhancement setting; please check your configuration.

Sure, the DomainModel Project is marked for enhancing.

You can download the solution at http://root.startp.de/trans/LogAnalyzer.zip
Can you explain where (in which project) to put the config for database access?

thanks
alex.
0
Alexander Becker
Top achievements
Rank 1
answered on 27 Jan 2010, 07:38 AM
Hello,

nobody can help me with this problem?

alex.
0
Accepted
Damyan Bogoev
Telerik team
answered on 27 Jan 2010, 10:02 AM
Hello Alexander Becker,

Sorry for the late response. You can fix those problems by slightly modifying the RawLogEntryRepository class methods as shown below:

Public Sub New()
 ObjectScopeProvider.AdjustForDynamicLoad()
 scope = ObjectScopeProvider.ObjectScope
End Sub
Public Sub Save(ByVal RawLogEntry As DM.RawLogEntry)
 scope.Transaction.Begin()
 scope = ObjectScopeProvider.ObjectScope
 scope.Add(RawLogEntry)
 scope.Transaction.Commit()
End Sub

Hope that helps.

Regards,
Damyan Bogoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Alexander Becker
Top achievements
Rank 1
answered on 07 Feb 2010, 05:03 PM
Thank you,

the project now works like expected.
But I have another question about the app.config files.

there is an app.config in DataLayer and in DomainModel.
I would expect mapping informations within DomainModels app.config and database-connection specific configurations in DataLayers app.config.
The mapping infos are within DMs app.config, inside DLs app.config there are database-connection infos.
But there are the same DB-Conn infos inside DLs app.config, too.

When I comment-out the connections or backendconfigurations section in either of the app.config the project does not work anymore.
Is there a detailed documentation about these configfiles with multilayered apps?

The mapping config is static, so compiled into the DLL as ressource is ok.
But how can I config the DB-connection details at runtime by code?
I do not have OAEnabled the console exe project, so I have to ORM specific config in this app.config.

thanks
alex

0
Alexander Becker
Top achievements
Rank 1
answered on 07 Feb 2010, 07:41 PM
Hello,

I found some useful informations about my question above, so I'll answer myself.

Setting Connection String through code without app.config/web.config
seems to be nice, but works only with OA Q1/2010 release (not available right now, 02/2010)

Understanding Where to Set Connection Strings in OpenAccess
Improving OpenAccess ObjectScopeProvider for Runtime Connection Config
blogs from Todd Anglin explaining details of config handling

so far so good, now let's see how this works...
alex.






0
Damyan Bogoev
Telerik team
answered on 09 Feb 2010, 03:25 PM
Hi Alexander Becker,

You could find useful the following articles about handling the connection strings inside an application:
"Using Connection Strings with Telerik OpenAccess ORM";
"Handling multiple database connections with Telerik OpenAccess ORM";
"Managing database connection settings of web sites and web applications during deployment";
Hope that helps. If any other questions arise please contact us back.

Greetings,
Damyan Bogoev
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Development (API, general questions)
Asked by
Alexander Becker
Top achievements
Rank 1
Answers by
Chris Jansen
Top achievements
Rank 1
Alexander Becker
Top achievements
Rank 1
Damyan Bogoev
Telerik team
Share this question
or