Skip to main content

Data from multiple tables in RIA Services

Recently, I had a requirement to display combined data from multiple tables in a Silverlight page. For this I had to use WCF RIA services to get the data from the database and send it back to the client for use. To be very specific on the requirement, I had 2 tables - Employee and Address and I had to display Employee information and its various types of Address information.

Since RIA Services work well with Entity model and generates methods for single table operation, using the same we can create domain service methods to deal with data from multiple tables. A data class needs to be created with combined fields from multiple tables. In my case, I created a data class EmployeeAndAddressDetails with attributes/columns from Employee and Address tables and created an entity model of these 2 tables from the database.

Then we need to create a IQueryable domain method to fetch data from these 2 tables. The return type should be IQueryable template class pointing to the data class created above (EmployeeAndAddressDetails).

Inside the method, write the query to fetch data from 2 tables selecting the required columns from the tables and populating the data class.

This method will return the required IQueryable data class.

Comments

Popular posts from this blog

Office 2013 Installation Error : Code 1603

Wanted to share one error that I got while installing Microsoft Office Professional 2013 for which I had to spend almost 3 days to find the root cause. I also googled and found that many people have also faced the same issue but did not get if anyone had the solution. Sharing the solution that worked for me. Thanks to Dhaval Metrani, my colleague, who also helped me with this. If you get the following error in the log file (in the %temp% folder) while installing Office 2013 Failed to install product OSMMUI.msi ErrorCode: 1603  and the detail log shows ERROR: The network address is invalid then the same is because of Task Scheduler service is not enabled on the machine. 1603 is a generic error and some people have mentioned that the same could be related to deleting/renaming  %programdata% /Microsoft Help but the solution seemed to be related to Task Scheduler when the exact error was related to 'Network address invalid'. By default in Windows 7 and Windows Vista ...

SBOM, a key building block in supply chain risk management

In my previous blog, I talked about what software supply chain attack is all about. It occurs when a threat actor infiltrates a network and employs malicious code in the software before the publisher sends it to their customers and then it compromises the customer’s systems. Such attacks affect all users of the compromised software and can have widespread consequences for organizations and their infrastructure and data. Traditionally, organizations developed applications in-house and this enabled developers to gain control over the entire codebase. However, this model cannot meet today’s time-to-market demands. As the expectations and pace increase, it’s impossible to meet the demand with home grown software. So, there is a need for open source software contributed by software professionals around the world. Open source software facilitates rapid development and release cycles. It enables developers to incorporate ready-made components into their application so they can quickly release...

The fast-paced lifestyle of developers...

When we talk about software world, what’s the first thing that comes to your mind? Programming - right? Developers play a very important role in turning technology ideas into reality. It’s ultimately the code that runs on the computer providing an interface to the end users or systems. Empowerment of developers has evolved over the last few decades from assembly level programming to more sophisticated software programming. It continues to evolve and provide enormous opportunities to transform the life of a developer which in turn transforms the business that relies on technology.   When I started my professional career in late 90s, the technology world was limited but fascinating. Computer technology was something that every technologist wanted to be associated with. We had only a few options to choose from and I was fortunate to work on programming languages such as Java, Visual C++, etc. My first programming language Fortran (as part of my undergraduate course) was really di...