Eager loading child properties using LINQ to CRM - linq

Is there anyway I can eager load client defined child properties on a CRM entity using the LINQ to CRM Provider supplied in SDK 4.0.12? I'm looking for something the same as the pattern in Entity Framework as shown here. I'd love to be able to do this so we can align our repository interfaces with those we already have against EF.
As an aside, I know I can do it client side via a WCF Data Service exposing my DataContext and then use the .Expand() extension method. Therefore, it doesn't seem like such a stretch to allow me to perform the same at the server.

Related

BreezeJS - Is there any way to use old style 'One controller to rule them all' with OData Web API?

I would like to expose the SQL Server Views via OData Web API but I don't want to create separate controllers for each views as there are too many of them and they will only accept GET verb for all the views.
I thought I can achieve this using BreezeController but it looks like I cannot as it is obsolete now (The package which has BreezeController attribute is marked as obsolete).
Is there any way to achieve this with OData Web API that works with BreezeJS?
The [BreezeController] attribute is not obsolete. In fact, it is central to the "happy path" Web API controllers you see in the Breeze samples. I wonder what lead you to think otherwise? What package are you using?
I'm referring to the ASP.NET Web API!
The ASP.NET Web API OData is a different matter. Despite "Web API" in the name, that is almost a completely different approach to server development with its own behaviors and wire format. It does not use the [BreezeController] attribute and never has.
I'm not sure what you meant by "view" in your phrase, "separate controllers for each view". I think you mean what I would call "type". For example, in OData you'd expect a "Product" endpoint for your Product entity type.
AFAIK, the Web API OData approach demands a separate controller per type. That's what Microsoft's Mike Wasson says in his tutorial. He writes ...
A controller is a class that handles HTTP requests. You create a separate controller for each entity set in your OData service.
BreezeJS supports Web API OData too ... although there are limitations imposed by the current Microsoft implementation that may give you pause.
We are working through these with the OData team and hope to have better news in the coming months.

MVC WebAPI with SPA

I am new to the WebAPI. I have 4 entities:
Location
Service
Item
Application
I have read several WebAPI tutorials. They all seem to have CRUD methods in each API Controller that deals with single entity. One functionality that I need is to simulate cascade dropdown and cascade update where Location determines range of Service. Each Service determines list of Service Item. Each Item may be used in a list of Application. The question is
Do I create 4 API Controllers with CRUD methods?
I need all 4 objects on one form as List Boxes that allow multi-selection.
Along side the 4 List Boxes, how to show a list of combination of selected value that are saved to a database table?
Which javascript library or framework is the best for SPA (Single Page App)? I am currently leaning towards Backbone.js and HotTowel.js.
Thank you.
You could expose your service as an OData service. If you wish to support filtering, then you should use the separate OData NuGet package, and develop your controllers. In this case four controllers would suit.
Then, you can use a client side rich data library such as breeze.js to make building requests to the OData service straightforward. You would then use an MV* client side framework to provide two way bindings between the client side view models and the UI elements.
Hot Towel isn't a JavaScript library, it's a Visual Studio extension which allows you to create a new project as a starting point for your SPA. The template requires Visual Studio 2012 and the ASP.NET Web Tools 2012.2 update.
It uses breeze.js, Knockout.js for the binding, and Durandal.js for navigation, life cycle, and view composition.

How to Generate Typed Data Definition for Web Api Odata

I have read this document "http://jaydata.org/blog/how-to-use-jaydata-with-asp.net-web-api---i" and it shows a very clear and simple way to user web api odata, but in this example, all the data types are defined manually, and I read the words from the document
"The ASP.NET Web API provider does not use server generated metadata to setup the client. You need to provide the JayData library with some information about the data types your about to deal with. This at the moment you can only do manually. Version 1.2.7 of JayData brings Visual Studio development time support for autogenerating the client environment."
Currently, the version 1.2.7.1 is released, but I can't find any information that how to use some tools from jaydata to auto generate these data types.
Is there any document for this?
Yes, we promised it and we did a proof of concept but nobody has asked about it since that post, you're the first, so we think that our current users are happy with either creating the model manually or using WebAPI with oData where the model can be built either dynamically from $metadata or statically with JaySvcUtil.
I can not promise any date when we'll release it.
Can't you just use WebAPI with oData ?

Expose domain object metadata to breeze js and track changes

I wanted to start using breeze js with an existing application. This application already has existing service that expose domain objects that are mapped from entity framework data object.
I wanted to expose these domain objects meta data to breeze so i could use it to track these entities on the client side and save changes. When these changes are saved from breeze I would then work out server side what needed to be done to persist these changes to my data objects.
I've looked at the EF context provider supplied in the breeze samples and was wondering what would be required to create a new context provider that would wrap my domain model ( not DBContext) exposing its metadata and also implement custom saving logic?
Has anyone done this already? Is there pipeline for breeze I've had a look on the user voice site and it looks like Extensible saveOptions and queryOptions are already under review but there is not much detail.
There is a ToDo-NoEF sample provided in the samples zip found here. It shows how to communicate with an arbitrary IQueryable on the server. Is this what you were looking for?

Linq, Entity Framework and WCF

If I have a customers and orders relationship in my Linq or EF model, at the WCF service layer I can add an order to the customer by calling
Customer.Orders.Add(customer);
When I access my customer object on the client, and want to add an order, there is no Add method, and the Orders propery is an array. Is there any way I can work with my client side object, they same way as I do on the server?
You are not supposed to be doing that, as the objects on the client have only a semantic similarity to the service's objects - they are not the same types.
This is done to conform to one of the important tenets of service-orientation: Services share schema and contract, but not class.
However, when you generate the client-side proxy, there are options where you can choose to have collections represented by List<T> instead of arrays.
Maybe you should look into What is .NET RIA Services?, .NET RIA Services.
This describes, and provides tools for those scenarios

Resources