score:2
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
ContactPerson
type.
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 BeforeSaveEntity
method.
score:0
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.
Check the ContactPerson
class definition.
Source: stackoverflow.com
Related Query
- 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
- how i can get the item Of subGroup list Through the group List
- How to get flattened list from dictionary key query where values are lists?
- How can I get the index of an item in a list in a single step?
- How to get duplicate items from a list using LINQ?
- How do I get a distinct, ordered list of names from a DataTable using LINQ?
- How to get a distinct list from a List of objects?
- LINQ: How to get items from an inner list into one list?
- How to get distinct instance from a list by Lambda or LINQ
- How to get a list of the grouped values in linq groupby?
- How to get the sum of list of shorts using the extension method Sum()?
- How to get linq `ForEach` statement to return data on the method call being made for each list object?
- How to get Resharper to convert back to a foreach loop
- How to get only specific field from the list
- How do I get list of id's as int using LINQ
- How to get an object from a list based upon IEqualityComparer<T>
- How to get an empty list of a collection?
- How to get a list of week days in a month?
- How to get all elements except the n'th element in a List using Linq
- How to get top N elements of a list with LinQ?
- How to get list of intermediate sums in a functional way? Using LINQ?
- How to get distinct List from a custom list?
- How to get the list index of the nearest number?
- How to get a distinct, case-insensitive list using Linq and Entity Framework
- How to get a list of all subobjects contained in a list of objects?
- How to get "remainder" of query (all non-matched pairs) in LINQ and collect it in a list
- How to get list of objects from list of jobjects based on key exists or not?
- How to get unique values from two list of dictionaries using Linq?
- How can I get back from an un-typed Expression to a typed one?
More Query from same tag
- Select items from List A where the property is not in List B
- Understanding the processing pipeline
- Entity Framework confiusing behavior when pulling data from db into list
- How to get date difference linq
- login info sql windows authentication
- LINQ to SQL group by to a blank row of data?
- How to get Max String Length in every Column of a Datatable
- Compare two lists that contain a lot of objects (3th part) "those objects have different type"
- C# where does the dbml file come from?
- Using LINQ to group a list of objects
- What is a good way using LINQ To SQL to update multiple tables through a view?
- Grouping By bool produces wrong result
- linq excluding one result set from another
- LINQ Group by error: "does not contain a definition for 'GroupBy'"
- Using DefaultIfEmpty in Linq - problem substituting a null value for a default value
- I am trying to add Linq result in Datatable but getting Error
- Selecting last record by linq fails with "method not recognised"
- type ObjectQuery or DbQuery Error when updating a object
- Custom Where expression
- choose a few id from db C#
- how to use linq instead of foreach to get an List<object>
- Linq and arrays.(does e=element?)
- Looping through List values in C# and saving them to a CSV
- Extract value from json in a database column using linq
- Finding an item in a list in c#
- I need to convert my SQL statement to linq I've tried to use Linqer but that gave no magic
- LINQ - Preserve order across objects with .Any()?
- where on LINQ query
- Potential Optimised alternative linq query for finding non Existent records within a set of Ids
- Why Doesn't My Anonymous Method Work in a Loop?