wcf-data-services

How to Host WCF REST Service and WCF Data Service in the same global.asax

冷暖自知 提交于 2019-12-06 07:35:06
问题 I have a WCF REST web service that is hosted via a service route in global.asax which looks like this; protected override void RegisterRoutes(System.Web.Routing.RouteCollection routeTable) { routeTable.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(UserService))); } I am wondering whether or not it is possible to also host another web service (which is a WCF Data Service) in the same application. protected override void RegisterRoutes(System.Web.Routing.RouteCollection

How do I setup config files for WCF Data Service (odata) with EF 6

限于喜欢 提交于 2019-12-06 07:24:11
问题 I have a data service up and running, but I'm getting this error: The remote server returned an error: (413) Request Entity Too Large. I have tried a number of things to fix this with no luck. I have set the uploadReadAheadSize on the Web Site and the Data Service in IIS to the max setting. I have also tried a number of different setups for the config files. Here is the current app.config for the client: <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding

How to consume a complex object from a sproc using WCF Data Services / OData?

为君一笑 提交于 2019-12-06 02:41:30
问题 Using WCF Data Services (and the latest Entity Framework), I want to return data from a stored procedure. The returned sproc fields do not match 1:1 any entity in my db, so I create a new complex type for it in the edmx model (rather than attaching an existing entity): Right-click the *.edmx model / Add / Function Import Select the sproc (returns three fields) - GetData Click Get Column Information Add the Function Import Name: GetData Click Create new Complex Type - GetData_Result In the

Which is better for building an API for my website: MVC or Ado.net data services?

ⅰ亾dé卋堺 提交于 2019-12-06 02:24:04
问题 I have a website built with MVC, and now I want to build an API for this website, to let users to use this API to implement different website, web services, plugins and browser extensions. I went through this article but didn't get yet which to use. General info about the API I want to build: The user of the API will have a key user name and password to be able to use the API. API will let users add content to my DB after validating this data. API will let users upload images to my server.

WCF Dataservice - modify object before returning results?

柔情痞子 提交于 2019-12-06 02:20:49
I am using WCF data services and I have a few fields/properties that I want to "blank out" (set value to empty string or null) before sending back to client. For example: User table has password column which I do not want to pass the value to the client. This is one example, there are other such columns in the app that the value should be excluded for security/privacy reasons. Sorry for such a basic question, I'm new to WCF dataservices and have not found any promising leads yet. I've tried QueryInterceptors but no luck. Can someone point me in the right direction? Thanks IMO this is out of

WCF DataService with Entity Framework: TimeSpan support

蓝咒 提交于 2019-12-06 01:33:47
I am trying to create a WCF Data Service over an Entity Framework Object context that exposes a number of System.TimeSpan properties. However, when I try to access the service, I get the following error: 'The property 'ScheduledDepartureTime' on type 'DepotRoute' is of type 'Time' which is not a supported primitive type.' I have tried using DataServiceConfiguration.RegisterKnownType(typeof(TimeSpan)) as well as DataServiceConfiguration.EnableTypeAccess(typeof(TimeSpan).FullName) but neither of these seem to make any difference - I still get the error... public static void InitializeService

How to dynamic add filters to a LINQ query against an Odata Source in C#

喜欢而已 提交于 2019-12-05 18:36:24
I have a query like the following var query = (from x in NetworkDevices where x.Name == "blabla1" || x.Name == "blabla2" select x ); and i'm running it against an Odata endpoint, so it effectively gets translated into the following URL https://targetserver/endpoint.svc/NetworkDevices()?$filter=Name eq 'blabla1' or Name eq 'blabla2' So i want to dynamically add lots of those where filters... In C# i can just keep adding it to my query, but that isn't dynamic. I want to do it at runtime. If i was calling this from Javascript, well i can easily just update the URL as well. My Question, is in C#

How to send list of objects to WCF service?

↘锁芯ラ 提交于 2019-12-05 18:23:43
I'm building WCF service and I would like to accept List as a parameter to one of my method. Here is my code: [ServiceContract] public interface IProductService { [OperationContract] int InsertProducts(List<Product> products); } [DataContract] [KnownType(typeof(List<Product>))] public class Product { [DataMember] public int ProductId{ get; set; } [DataMember] public string ProductName{ get; set; } [DataMember] public List<Product> Products { get; set; } } When I run service it gives me an error. This operation is not supported in the WCF, because it uses NameSpace.Product[] When sending a

Operation instead of query interceptor (WCF Data Services)

折月煮酒 提交于 2019-12-05 13:29:59
I was reading about query interceptors . I was disappointed because thats more like a filter instead of an interceptor. In other words you can eather include records or not include them. You are not able to modify records for instance. If I want to create a query interceptor for my entity Users I could then do something like: [QueryInterceptor("Users")] // apply to table users public Expression<Func<User, bool>> UsersOnRead() { return cust => cust.IsDeleted == false; } What if I instead create the operation: NOTE IS VERY IMPORTANT TO HAVE THE OPERATION NAME JUST LIKE THE ENTITY NAME OTHERWISE

Building 'flat' rather than 'tree' LINQ expressions

浪子不回头ぞ 提交于 2019-12-05 11:26:36
I'm using some code (available here on MSDN) to dynamically build LINQ expressions containing multiple OR 'clauses'. The relevant code is var equals = values.Select(value => (Expression)Expression.Equal(valueSelector.Body, Expression.Constant(value, typeof(TValue)))); var body = equals.Aggregate<Expression>((accumulate, equal) => Expression.Or(accumulate, equal)); This generates a LINQ expression that looks something like this: (((((ID = 5) OR (ID = 4)) OR (ID = 3)) OR (ID = 2)) OR (ID = 1)) I'm hitting the recursion limit (100) when using this expression, so I'd like to generate an expression