You can send projection data to BreezeJS and turn them into a custom
EntityType you've defined on the client. You can't expect that
ContactPerson type to show up in metadata from the server that has been generated by Entity Framework; it's a DTO and not part of the model that EF knows about.
That shouldn't stop you from defining
ContactPerson on your Breeze client. Learn about how to create client-side metadata in the docs.
It's worth noting that you do not have to define all of your metadata on the client to take advantage of this feature. Just add this
The next trick is getting BreezeJS to realize that your projection data should be transformed into
ContactPerson entity on the client.
Breeze won't recognize the anonymous type data by default. You can give it some help with the
toType query clause. You can uncomment that clause in your query after you have defined the type in your client metadata.
return EntityQuery.from("PersonsFlattened") .toType("ContactPerson") // Should work after defining ContactPerson on client .orderBy(orderBy) .using(self.manager).execute() .then(querySucceeded, self._queryFailed);
You won't need the
toType clause if you project into a server-side
ContactPerson type and connect the dots between the "PersonsFlattened" endpoint and your custom client-side
ContactPerson type in metadata. I think I'd rename that endpoint "ContactPersons" for consistency.
N.B.: I trust you realize that you've defined read-only types. Breeze doesn't know that so if you make changes to a
ContactPerson entity in BreezeJS, the manager will try to save it. Your save attempt will throw on the server unless you catch the incoming change on and do something marvelous with it, perhaps in a
The exception "The entity or complex type 'SiteTrackerModel.ContactPerson' cannot be constructed in a LINQ to Entities query" is related to how the class
ContactPerson is declared. LINQ to entity can only construct pur Data Transfert Object : class containing only public properties with trivial getter and setter and without constructor.
ContactPerson class definition.
- How to get a flattened list back to breezejs through webapi2?
- How to loop through a child list of objects in Entity Framework 4.1 code first
- List or Array of String Contain specific word in Html Source Code
- c# Linq or code to extract groups from a single list of source data
- Generating the Shortest Regex Dynamically from a source List of Strings
- Enumerating through list of expressions to filter collection
- Iterate through LINQ Results List
- LINQ Source Code Available
- .NET 4 Code Contracts: "requires unproven: source != null"
- LINQ query returns old results when source list is re-initialized
- Copy a list of objects to another typed list in one line of code
- C# - Linq optimize code with List and Where clause
- StackOverflowException trying to return a Linq query result as a List through a WCF Service
- creating Linq to sqlite dbml from DbLinq source code
- How can i copy data table records of different field name based on mapping list evaluating condition on source data table?
- How to convert List to a string and back
- Is there a way to loop through properties of a list of objects using linq?
- How to enumerate through list of Func<TSource,TResult> to filter collection
- Linq list of enumerators seem to be recreated when accessed through linq
- How to remove selected data that found on another list and take last 6 id through LINQ without foreach loop
- C# Linq IQueryable select flattened nested object list
- How to change the precision and the scale of decimal globally through code first?
- Convert this LINQ code back to a Loop (or Why is this object sometimes null)
- Code to apply expression tree directly to List
- Search by zip code and filter list within specific radius?
- I can't get pagination to show up in every page on a GridView with a list as source
- How to cast result back to generic list (using linq to object)?
- Remove Back to Back Duplicate Entries from a List using Linq Method Syntax
- Is there any way to map a ISO Currency Code back to a culture string?
- Linq to Entities - 'where' to bring back a list of Products and associated items checking both are enabled
- Select only first record within a time interval
- Sorting OrderedEnumerableRowCollection .. strings like 00-000, 01-000 are not sorted as expected
- Why is the method not getting called?
- VB.net Linq Select Distinct
- Beginner mistake in Linq Extension Methods with Entity Framework
- Checking for the existence of an object in a collection (of T)
- Transfer selected DataGridView row to a new DataGridView in another form
- Random Top query in MongoDB using C# Linq
- LEFT JOIN with LINQ produces NULL reference exception
- Check if one list contains any elements from another
- LINQ Distinct not working as expected
- Is this lambda expression possible?
- Outer join query using LINQ to Entities
- Convert IEnumerable To List
- Need to turn LINQ Query from Normal JOIN into RIGHT OUTER JOIN
- LINQ for this foreach
- Complex OrderBy: Statement body cannot be converted to expression tree
- How to output a relational object using Linq on View models in Entity Framework Core
- Ling Query on DataTable with single dynamic Where Clause
- Use LINQ to refactor a WPF, grid.Children iterating method