wcf-data-services

How do i get an inner join in a WCF Data Service

眉间皱痕 提交于 2019-12-01 14:01:51
Lets say i have 2 tables, table1 and table2, with a shared key "id" if i want an inner join of those two tables using sql, i'd do something like select id, x, y, z from table1 inner join table2 on table1.id = table2.id I now get rows in table 1 that only intersect occur in table 2. how do i get the equivalent in wcf data service/odata linq syntax? i'm expecting something like: var q = (from t in svc.Table1.Expand("Table2") where t.Table2.Any() select t) as DataServiceQuery<Table1>; but that gets me an exception about Any() . I've tried .Join and that isn't supported either. I've tried .Count

How do i get an inner join in a WCF Data Service

五迷三道 提交于 2019-12-01 12:17:48
问题 Lets say i have 2 tables, table1 and table2, with a shared key "id" if i want an inner join of those two tables using sql, i'd do something like select id, x, y, z from table1 inner join table2 on table1.id = table2.id I now get rows in table 1 that only intersect occur in table 2. how do i get the equivalent in wcf data service/odata linq syntax? i'm expecting something like: var q = (from t in svc.Table1.Expand("Table2") where t.Table2.Any() select t) as DataServiceQuery<Table1>; but that

WCF Data Service gives 404 when making OData requests for derived types

只谈情不闲聊 提交于 2019-12-01 08:42:27
问题 I think I'm missing a trick getting WCF data services/OData/Inheritance working; I've created a couple of simple tables: create table Super ( superID int IDENTITY(1,1) not null PRIMARY KEY, supername nvarchar(55), ) create table sub ( superID int not null, extraData nvarchar(100), FOREIGN KEY (superID) REFERENCES Super(superID) ) insert Super values('abc') insert Super values('def') insert Super values('ghi') insert Super values('jkl') insert Super values('mno') insert sub values(1, 'pqrstu')

How to use “SelectMany” with DataServiceQuery<>

微笑、不失礼 提交于 2019-12-01 07:55:43
I have the following DataServiceQuery running agaist an ADO Data Service (with the update installed to make it run like .net 4): DataServiceQuery<Account> q = (_gsc.Users .Where(c => c.UserId == myId) .SelectMany(c => c.ConsumerXref) .Select(x => x.Account) .Where(a => a.AccountName == "My Account" && a.IsActive) .Select(a => a)) as DataServiceQuery<Account>; When I run it, I get an exception: Cannot specify query options (orderby, where, take, skip) on single resource As far as I can tell, I need to use a version of "SelectMany" that includes an additonal lambda expression ( http://msdn

Filter on Expanded entities in OData

…衆ロ難τιáo~ 提交于 2019-12-01 07:25:32
问题 How to apply filtering conditions on expanded entities in OData ? Suppose I have master entity as home having fields homeId, StateId, CountyID, Address and sub entities state as StateId, StateName and county as CountyID, CountyName I need to get the home addresses and Ids with a filter condition with state name and county name. How should be the url? 回答1: Using the $expand keyword OData query should be something like: /home/?$filter=state/statename eq 'STATE' and county/countyname eq 'COUNTY'

WCF DataServices (CTP2): There is a type mismatch between the client and the service

佐手、 提交于 2019-12-01 06:25:15
I'm using WCF Dataservices CTP2 with Entity Framework 4.1. Now then I'm trying to get any data through my datacontext I get this exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: There is a type mismatch between the client and the service. Type 'Crm.Objects.Segmentation' is not an entity type, but the type in the response payload represents an entity type. Please ensure that types defined on the client match the data model of the service, or update the service reference on the client. at

How do I expose a TimeSpan through a WCF Data Service?

无人久伴 提交于 2019-12-01 06:13:09
I am creating a WCF Data Service for my database of appointments. I'm storing the appointment as a DateTime with a duration of type TimeSpan. When I attempt to access my data service, I get the following error: "The server encountered an error processing the request. The exception message is 'The property 'Duration' on type 'Appointment' is of type 'Time' which is not a supported primitive type.'. See server logs for more details." Any idea how I can represent a time duration and have it accessible through my WCF Data Service? I would suggest exposing a new property for serialization (marked

How to use “SelectMany” with DataServiceQuery<>

北城以北 提交于 2019-12-01 05:42:21
问题 I have the following DataServiceQuery running agaist an ADO Data Service (with the update installed to make it run like .net 4): DataServiceQuery<Account> q = (_gsc.Users .Where(c => c.UserId == myId) .SelectMany(c => c.ConsumerXref) .Select(x => x.Account) .Where(a => a.AccountName == "My Account" && a.IsActive) .Select(a => a)) as DataServiceQuery<Account>; When I run it, I get an exception: Cannot specify query options (orderby, where, take, skip) on single resource As far as I can tell, I

How do I expose a TimeSpan through a WCF Data Service?

三世轮回 提交于 2019-12-01 04:58:35
问题 I am creating a WCF Data Service for my database of appointments. I'm storing the appointment as a DateTime with a duration of type TimeSpan. When I attempt to access my data service, I get the following error: "The server encountered an error processing the request. The exception message is 'The property 'Duration' on type 'Appointment' is of type 'Time' which is not a supported primitive type.'. See server logs for more details." Any idea how I can represent a time duration and have it

Linq query error

柔情痞子 提交于 2019-12-01 00:49:17
I am using following Linq query: from p in People where p.Name == "George Lucas" select p.TitlesActedIn where TitlesActedIn is a list. People and TitlesActedIn are associted But I am getting error: InvalidCastException: Unable to cast object of type 'System.Linq.Expressions.PropertyExpression' to type 'System.Data.Services.Client.ResourceExpression'. Please suggest solution. A very simple way to do it: var query = People .Expand("TitlesActedIn") .Where(p => p.Name == "George Lucas") .First() .TitlesActedIn.Select(t => t.ShortName); query.Dump(); Its important to note, that this will crash if