4 Answers, 1 is accepted
If you need a join between two or more classes (tables) in a query, you can use LINQ to achieve that with OpenAccess ORM. Here you can find a general guidance for using LINQ with Domain Models, in case you are not yet familiar with this feature.
Do not hesitate to contact us in case you need further information or you have any questions regarding how to build your query.
Regards,
Ivailo
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>
Please allow me to ask you some very basic questions that i think will help minimize all the other questions i have. I am new to ORM's.
So let me get this all down and please tell me if i am right or wrong.
The OpenAccess ORM is meant to become the applications DAL. However, if i want to do advanced queries on the database i still have to create classes in the DAL that queries the ORM in the way that i want. Correct?
That being said, the Domain Model is not the place where you would create these queries. The domain model builds our mapped classes to the database tables that i can access rather than accessing the tables themselves? But my DAL should still contain all the classes needed to query the DB, this is not the job of the ORM?
So in short, i still have to build out all the methods that access the databases/ORM and return the data in some way?
Thanks for your help in advance,
Duncan
To answer your first question, there are two approaches to querying your database using OpenAccess ORM:
1) Using the auto-generated classes of your Domain Model, you can directly write LINQ queries using the model as a context for the query. The queries can either be packed in dedicated classes or you can write them directly in any project that refers to your DAL assembly. This is the most commonly used approach and it is the one I have recommended in my previous post.
2) You can write your queries using our ADO API, which gives you the freedom to write any
SQL statements that might be needed by your application.
In any case, you need to have your classes defined and mapped to the database tables. Those definitions have to be in your DAL.
As for your second question, the Domain Model is just a context for database access. You will still have to define the specific queries you will need – either in your DAL or BLL, or even UI layer where appropriate. The value for you is that you will most probably be querying classes through LINQ, instead of tables through SQL.
Finally, you don’t need to build methods for accessing the database itself. You can just use your classes and OpenAccess ORM provides you the API needed to create, retrieve, update or delete data. However, for your complex functionality for working with data, you might have to create additional utility classes, working with OpenAccess ORM persistent classes.
There are different types of resources you can use to get started and SDK is probably the best option.
You can start by reviewing some introduction articles in the documentation, they are quite explanatory.
Then you can take a look at the SDK sample Linq101Samples (specifically for queries) and the 3 N-Tier development projects demonstrating separation of layers through different kinds of services. You can also check out some of the other samples based on your scenario.
Do not hesitate to let us know if you have further questions.
Greetings,
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>