how to Call database view in silverlight ria service project? - silverlight-4.0

Can we call database view useing Silverlight ria service and bind data to ui .If some , any samples.. in the web?
Is there any limitation.
?
Thanky

Yes you can. This post should be helpful. Once you have successfully created an entity, it should bind just like every other entity to UI components.

Related

Use WCF Data Contract as model for MVC view

I have started working on an application which is structured as follows:
UI - ASP.Net MVC web application
Service Layer - WCF
Entities - a simple class library (exposed by WCF layer)
Data Layer - for database interactions.
Till now, I was defining my models in Models folder of my web application, but now as we have decided to expose them by WCF service (as this application will be consumed by other applications as well), I need some help here.
I tried putting all my model definitions in Entity layer which is exposed by WCF service decorating them with data annotations as well as DataContract attributes. Now, I am able to reference these entities to bind them with my views. But, data annotation validations are not working for me.
Can anybody please help me for a workaround for this ? I have been searching through web for solution but almost all tell me to put a reference of entity layer in web application which will be tight coupling that we do not want. and the other option is to redefine all entities with data annotations in models folder of my web application,which will be duplicate kind of coding.
Is there any better approach for this? Any help appreciated.
Update:
To consume WCF entities, I have put a service reference in my web application. Now, just to check I modified that Reference.cs file by decorating my data Member explicitly with [Required] attribute and it is working fine. but, I understand these changes will go away whenever service code is generated.
Is there any way I can bring that Data annotation attribute here? Kindly help.
As for me It's bad idea, DTO for transfer, Model for MVC.
Look like similar problem
Why You Shouldn’t Expose Your Entities Through Your Services
DTO’s Should Transfer Data, Not Entities

Consuming a WCF service by a WPF client

I have created a wcf service and trying to consume by a wpf client. I am unable to see data in datagrid of my wpf client..Here is the code of both wcp & wpf
I have attached all the details in the following url..pls check it out n help me..
http://pastebin.com/8cVKrqci
There are 4 basic possibilities here:
You are not calling the WCF service
You are calling the WCF service but it is not returning any data
You are not binding the data to your datagrid
The datagrid is not refreshing after the data has been bound
You need to put some logging in your code to identify the problem.
Edit
Based on the comments, your problem is that the service is not running on the address that you are using.

Understanding the new Web API approach

I’m aware that not everyone uses a thorough architecture when developing an MVC application but let’s assume I have the following architecture:
App.Core --> Class Library (POCO or Domain objects)
App.Data --> Class Library (Repository and Entity Framework)
App.Service --> Class Library (Service layer with all business logic)
App.Web --> asp.net MVC 3.0 project
App.Data --> Has a reference to App.Core
App.Service --> Has a reference to App.Core and App.Data
App.Web --> Has a reference to App.Core and App.Service
Inside our MVC application we try to follows this approach:
Inside our Controller (within a method), we instantiate a ViewModel.
We fill that ViewModel calling methods from our App.Service Layer
Once the ViewModel is filled, we return it to the View (so the view
is now strongly typed).
This occurs 99.9% of the time. It is clean, we like it and it leverages itself pretty well..etc!
Now my question is the following:
If we decide to move our application to MVC 4.0 and start using the
new Web API approach, I’m not sure I fully understand where (or how)
it would fit in our current architecture?
Keep in mind, that we are open to change this around!
Should we create a new App.WebAPI layer that sits between the App.Service and App.Web?
This means inside our Controllers, we would no longer need to call the App.Service directly but instead the new App.WebAPI layer?
Or, leave the Web API inside the App.Web layer and make the Controllers call the other APIControllers which in turn would call the App.Service layer?
Not sure if I make any sense here…but please feel free to suggest anything as I’m curious on different inputs.
Thanks
There are a couple of cases to consider:
Do you want to make this Web API serve as service layer and data access for your MVC application? If, yes, then you should completely remove all references of App.Service from the ASP.NET MVC project and have it query the Web API instead to fetch the data. In this case the Web API sits between your ASP.NET MVC application and the data access. It is the Web API that talks to the service layer and exposes it over the HTTP protocol.
Or do you want to provide an additional API for your web site that can be used by other clients (other than web browsers)? In this case the ASP.NET MVC application and the Web API sit on the same layer. Both query your Service layer to fill view models, it's just that in the case of the MVC application you are passing those view models to views which in turn convert them to HTML whereas in the Web API layer you probably use slightly different view models but which are still populated from your service layer and are passed to the client used the corresponding serialization mechanism (JSON, XML, ...)
I know this is late but I was actually looking for the same advice and I found this post.
Wouldn't having "both the MVC and Web API sit within the same layer" mean more maintenance work on the code, or maybe duplication of code? isn't the mvc web considered as a browser client? .. to me it makes sense to have the WebAPI your only layer to everyone else and in turn it would call your service layer for processing.
What is the benefit of leaving both the Web API and the MVC talking directly to the service layer? Can't the web API be the wrapper around the service layer?

Client Side Binding using by Converting the WCF Services to JSON

We have a Requirement of Consuming the WCf Services which is hosted in IIS like http://localhost/someservice.svc.
We would like to consume that Service via java script and bind my sample data controls called grid view on client side itself.
I think this can be done by Serializing and deserialzing to JSON and consume the data source and bind the grid controls.
Pls Refer the below link
http://forums.infragistics.com/forums/p/48035/258346.aspx
I would like to Achieve my func like the above link.
Can you pls guide me to achieve this Tasks.
Thanks
Regards
N.Balaji
Balaji,
Yes, you can definitely enable your WCF service (whether within IIS or not) to use JSON.
You do need to make one choice: do you want to use that service from the ASP .NET AJAX framework, or do you want to create a more general solution that is not tied down to that framework's usage within the browser?
If it's the former, use WebScriptEnablingBehavior. If it's the latter, use WebHttpBehavior.
For either scenario, detailed instructions are available in the following two MSDN sections:
AJAX Integration and JSON Support
WCF Web Http Programming Model

Shared data object between WCF service and Silverlight app

I have a custom data entity (data object) that is exposed via a WCF webservice. The WCF service lives in a web application. I then have a Silverlight application with a service reference to that WCF service. When i add the service reference a proxy is generated, and that includes a version of the custom data entity.
How should i structure my code so that the data entity is declared in one place, and shared amongst the project containing the WCF service and any Silverlight applications that reference it? I want to eliminate the version of the data entity that is generated with the proxy.
There is a good example of how to do this here by Pete Brown. Using that approach you can use the same classes in both the Silverlight client and in the WCF service without having to use the generated objects.
Declare the data entities in the WCF service or a project that the service refereneces, then from the Silverlight project add the entities as links and make sure the "Reuse types in referenced assemblies" checkbox is selected from the Service Reference Settings dialog.
You can put the types in either the Silverlight or WCF side.
I have tried doing things this way and found that using DTOs instead and mapping them to the entities in the Silverlight side to be much cleaner and easier to work with although I did write a bunch of mapping code to get the DTOs into the entities and vice versa.
I´m not quite shure why anybody want to do that. You have to understand that the type you find in the proxy is a projection of the Type you have at Service server site. It´s defined in the *.g.cs files and gets generated new if you update the service reference.
In my opinion it´s the best way to have it declared in a single location, and project it. You need it in two places and it´s single defined.
I may be wrong anyway .....