This is a migrated thread and some comments may be shown as answers.

Newb Needs a little MVVM ORM help

3 Answers 157 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wayne
Top achievements
Rank 1
Wayne asked on 17 Jun 2013, 03:28 PM
Ok,

I am totally new to not only your ORM but MVVM...I believe I understand the basic concepts but every time I look things up I find someone doing something a different way!

What I have done so far...

I have a database with several tables. I have created a blank solution and added a Telerik Open Access ORM Class Library, MastersModel. I run the wizard and add a database first model and have it use the new Generate INotifyChanged and IDataError Options so I can use MVVM. Thats great! I am able to make minor changes to the model and everything builds and is happy!

I Then created a second project called MastersUI and its a WPF app. I copied the app.config for the connection string and added OpenAccess references. Now what! I'm lost. I created some folders to separate things up a little (Views\ViewModles). I created a class called TitlesViewModel but now I am lost...how do I query the data. I could use dbcontext in the viewmodel to get records using Linq but that breaks the INotifyChanged because I have to loop thorough the records to get them in to my observable collection. I can include snippets if needed.

I guess a newb just needs a little direction. I have used dbContext before to get data from your models with Linq and that was so easy
I thought why not include this in my MVVM learning!!! HA!

Thanks in advanced for any help!!!!

3 Answers, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 18 Jun 2013, 03:15 PM
Hi Wayne, 

I would suggest you to take a look at Telerik OpenAccess Samples Kit, we provide a sample "ASP.NET Web API with WPF MVVM" which demonstrates the best practices for using the WPF MVVM pattern and Web API services. In the WPF client application - "WebApiWpfMvvm.Client" you will encounter a full blown MVVM implementation. You can also click on the Open Documentation button for the example to access an end-to-end tutorial for building it.

I hope that helps. Please let me know if you need additional assistance or in case you have other questions.

Regards,
Boris Georgiev
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
0
Wayne
Top achievements
Rank 1
answered on 19 Jun 2013, 06:21 PM
Thanks for the suggestion...I will take a look at the sample although I am not sure I want to tackle WCF just yet but it is on my list along with Prism. But MVVM\WPF had to be first! I was able to get data finally without WCF and I think I got what I was doing wrong even got a simple command using delgatecommand to save the changes...NO SQL!!! That was quite awesome! I have one more question. I have two or threee databases in my implementation....can the ORM join accross Models or would it be best to develop a model for each specific use...what I men is a sales rep needs access to orders, custeomers, and inventory which are tables in two different databases...is that one enttities model in ORM or two that I can join in some sort of joined observablecollection...does that make sense??


Thanks again - you guys are awesoem in that you actually answer,
0
Boris Georgiev
Telerik team
answered on 24 Jun 2013, 03:33 PM
Hello Wayne,

Unfortunately it is not possible to join several databases in one model using Telerik OpenAccess ORM. For any database you will have to create a separate Domain Model and implement the links between different databases in your own business logic. 

Our recommendation is to have one model per connection string, as this is the most optimal way for OpenAccess to work. This way the whole metadata for a database is kept at one place in the internal metadata cache.
It is also possible to split one database to several models but this requires some additional code and we suggest it only in more special cases, for example when dynamic modules using different parts of the database are used.

If you need additional guidance or if you need any further assistance with OpenAccess ORM, please let us know.

Regards,
Boris Georgiev
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Tags
Getting Started
Asked by
Wayne
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Wayne
Top achievements
Rank 1
Share this question
or