Quantcast
Channel: WCF Data Services forum
Viewing all 877 articles
Browse latest View live

Any update to docs, examples for WCF support of OData annotations?

$
0
0

The recent WCF Data Service 5.3 and 5.4 release notes mentioned improvements in support for OData 3.0 annotations.  However, the only mention I can find of how to access OData annotations in WCF is this "Vocabularies in WCF" article from 2011.

Is this 2 year old article still current/valid and representative of WCF's current access to OData annotations?  Or is there something more recent that reflects WCF developments of the past 2 years? Anything? Please?

Thanks,

-Danny

P.S. My primary interest is how to produce OData annotations in a WCF Data Service that does not use a EDM data model. I've written my own provider for POCOs using the query engine from the WCF Data Toolkit.  Secondary interest is how clients can consume/access those OData annotations using Service Reference generated proxy classes.


http://dannythorpe.com


WCF Data Services Server - Performance issue during projection.

$
0
0

Hi,

I have been working on performance optimizing our custom data service provider. In this proccess I have run into a bottle neck in WCF Data Services Provider (the server part).

The issue is related to GET requests (queries) containing projections (a $select). It seems that for each returned entity the WCF DS server framework will callTryResolvePropertyName on the ResourceType for each property in the projection.

Now - imagine I am returning 10000 entities and projecting 20 properties. This will result in 200000 calls to TryResolvePropertyName. Now if look at the implementation ofTryResolvePropertyName with ILSpy, we'll end up in this...

internal ResourceProperty TryResolvePropertyName(string propertyName, ResourcePropertyKind exceptKind)
{
	return this.Properties.FirstOrDefault((ResourceProperty p) => p.Name == propertyName && (p.Kind & exceptKind) == (ResourcePropertyKind)0);
}
 

If my ResourceType has 200 properties and i am only projecting the 20 last properties in the Properties Collection, this alone takes around 1.2 seconds. In my setup this around 50% of the entire querying processing time on the server - including roundtripping to a database on another machine and getting the response back to the client.

I know you are dedicated to performance (you often state that on the blog), could you please have a look at this.

As a comparison: If the Propertis collection were a Dictionary<srting,ResourceProperty> 200000 lookups could be made in 0.05 seconds.

Another approach would be to only do this havy stuff for the first entity in the feed.

Is there any way to hook into this property resolving stuff, so I can do a more efficient implementation myself?

Btw. This is on WCF Data Services 5.5.0 with a custom provider.

Kind Regards

Uffe


WCF OData $top with "nextLink"

$
0
0

I'm building a WCF Data Service and I found a strange behaviour when I make a GET with the $top parameter set.

I was expecting, as I found on many sources on the Internet, that the response would give a "nextLink" in case that there were more items than the specified in the $top parameter... that doesn't occur! Why!? Am I doing something wrong? How can I control the page size on the client side and use the "nextLink" to navigate to the next page?

If I omit the $top parameter, the server controls the page size and retrieves the "nextLink" parameter... but if I use the $top parameter, server never returns "nextLink"! Is this a bug?

Best regards,

Fernando Rocha



.Net Client fails to Update Odata Controller

$
0
0

Created an Odata MVC WEb API. Running it Locally IIS Express 7.5 to debug it.

Created a .Net WPF client app.

Here is code to load from client:

private Container _proxy;

private DataServiceCollection<EF_WO> _wos = new DataServiceCollection<EF_WO>();

I am able to Get data and can step through the Odata call.

I am able to Insert and Delete Data and can step through the Odata call

I Cannot Update, when I change values in a WPF datagrid and call Savechanges . It will not call the Odata UpdateEntityKey override

Even if I manually update the dataservice collection from the client it will not update. It gives a generic DataserviceRequestError.

I looked at the Entity and its state is modified...

The IIS Express Log says a 404 Error?

Please Help...

Server :

Using Entity Framework 5

Using Oracle 11.2.30.2 Client

Project is ASP.Net WEB API MVC 4

Odata

Client:

WPF application using a datagrid

Bing News Search API Results

$
0
0

I am working on a custom news widget for a client. He wants to include news that only has a particular company name as well as one or more industry terms. For companies [Company A, Company B, Company C], he wants to display aggregated results (newest first) using the following search terms.

"Company A" AND ("electric vehicle" OR "PHEV" OR "energy storage" OR "lithium-ion" OR "capacitor" OR "graphite" OR "separators" OR "community energy storage" OR "electricity storage" OR "advanced batteries")"Company B" AND ("electric vehicle" OR "PHEV" OR "energy storage" OR "lithium-ion" OR "capacitor" OR "graphite" OR "separators" OR "community energy storage" OR "electricity storage" OR "advanced batteries")"Company C" AND ("electric vehicle" OR "PHEV" OR "energy storage" OR "lithium-ion" OR "capacitor" OR "graphite" OR "separators" OR "community energy storage" OR "electricity storage" OR "advanced batteries")
  1. I can't find the exact limitations of the Bing News Search API - what are the maximum number of terms?
  2. The results that are returned don't necessarily contain the company name. How can this be explained?

Cannot materialize complex or primitive type - WCF Data services

$
0
0

i use WCF Data services along with Entity framework to talk to the SQL Server database. The data is not directly accessed through the ORM but instead ,the stored procedures are used to fetch and insert data.

I do a function import on the Entity framework and invoke them through the Web get calls from the WCF Dataservice.Most of the times these procedures return collection of Complex types(generated from EF).

This is how i execute from my asp.net mvc app

Context.Execute<T>("<service uri>","GET",true);

Here is the error i get everytime

Cannot materialize a collection of a primitives or complex without the type being a collection.

Does the latest WCF Data services client does not support collection of complex types.

I am using the latest version of WCF Data services client which is 5.5

I am stuck on this for few days now.What is the actual reason for this error

WCFDataService Firefox/Chrome error

$
0
0

When calling our WCFDataService from firefox or chrome we are getting a missing file error that does not happen in IE.

The error is as follows and the call to the error is at the bottom.

(I tried to format it but MSDN is acting weird today.)

[FileNotFoundException: Could not load file or assembly 'App_Web_k0ezqwsd, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)+0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +255
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172

  

[ServiceActivationException: The service '/ItDataServices.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not load file or assembly 'App_Web_k0ezqwsd, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +901424
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178702
   System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107

The code to call the method is as follows           

_entities.BeginExecute< LoginResult>(new Uri(String.Format("GetUserLogin?username='{0}'&password='{1}'&release='{2}'&pcName='{3}'&macAddress='{4}'&ipAddress='{5}'&isNoc={6} ", CurrentUser.UserName, CurrentUser.Password, release, pcName, macAddress, ipAddress, 0), UriKind.Relative), result => GetUserLoginCallback(result), _entities, ODataConstants.MethodGet, false);

WCF Self-Hosted Data Services with CORS and Basic Auth support

$
0
0

I'm building a WCF Self-Hosted Data Service (OData, by the way) and I'm using Basic Authentication to authenticate users. It wasn't very hard, I just needed some configuration steps, build a UserNamePasswordValidator and a IAuthorizationPolicy - DONE.

Now I need to support CORS (Cross-Origin Resource Sharing). I've tried many implementations, some documented (for instance, this), other made by myself.

The problem is, if I let Basic Auth enabled, because the CORS preflight request (OPTIONS) doesn't have the 'Authorization' header, and I can't manipulate the request (of course, or that would defeat the purpose for the browser to do it), I'm unable to intercept/respond the request on the server. I can't even check how far does it go! I've tried to implement many Behaviours, Bindings, Managers, etc., but I can't catch that request, not even on "DataService<>.OnStartProcessingRequest()".

If I disable Basic Auth on the server side, I'm able to catch the CORS preflight request and eventually respond to it (using a IDispatchMessageInspector and a BehaviorExtensionElement), but that way I have to implement Basic Auth on my own... damn.

Please help me. How do I support both? How can I intercept the CORS preflight request before Basic Auth simply respond 401 Unauthorized?


Implementing WCF Data Service without Entity Framework

$
0
0

Hi,

  I would like to know if there is a way to implement WCF Data Services exposing data from SQL Server without using Entity Framework. I did some search on the internet and most samples seem to suggest that we have load the entire data in memory. 

Thanks

 

 

UseJson and IgnoreMissingProperties

$
0
0

I am using the new WCF DataServices 5.1 and trying to convert my client app from Atom to JsonLight but I am having some problems with the datacontext setting IgnoreMissingProperties. This is quite important because I want to avoid a substantional rewrite of my code.

I have one of many generated client entity object which has a custom property marked with a special attribute. This property is not defined in the EDM. Previously I intercepted the serialization of the entity using the datacontext WritingEntity callback and filtered out the custom property to avoid getting errors when writing data.

When I try to set the context.Format.UseJson() then I can read data from the server without problems but when posting changes to the server for the client entity object I get the exception below. The strange thing is as far as I can see in the code for ReadUndeclaredProperty it is only supposed to throw an exception if the flag IgnoreUndeclaredValueProperty is not set.

From ODataJsonLightEntryAndFeedDeserializer

if (!base.MessageReaderSettings.UndeclaredPropertyBehaviorKinds.HasFlag(ODataUndeclaredPropertyBehaviorKinds.IgnoreUndeclaredValueProperty))
            {
                throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_PropertyDoesNotExistOnType(propertyName, entryState.EntityType.ODataFullName()));
            }

Here is the exception

System.Data.Services.Client.DataServiceRequestException: An error occurred while processing this request.
---> System.Data.Services.Client.DataServiceClientException: {"odata.error":{"code":"","message":{"lang":"nb-NO","value":"An error occurred while processing this request."},
"innererror":{"message":"The property 'Name' does not exist on type 'Baze.DataEngine.DataModel.BazeInputAdapter'.
Make sure to only use property names that are defined by the type.","type":"Microsoft.Data.OData.ODataException","stacktrace":"   
at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadUndeclaredProperty(IODataJsonLightReaderEntryState entryState, String propertyName, Boolean propertyWithValue)\r\n   
at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadEntryPropertyWithValue(IODataJsonLightReaderEntryState entryState, String propertyName)\r\n   
at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadEntryContent(IODataJsonLightReaderEntryState entryState)\r\n   
at Microsoft.Data.OData.JsonLight.ODataJsonLightReader.ReadAtEntryStartImplementationSynchronously()\r\n   
at Microsoft.Data.OData.JsonLight.ODataJsonLightReader.ReadAtEntryStartImplementation()\r\n   
at Microsoft.Data.OData.ODataReaderCore.ReadImplementation()\r\n   
at Microsoft.Data.OData.ODataReaderCore.ReadSynchronously()\r\n   
at Microsoft.Data.OData.ODataReaderCore.InterceptException[T](Func`1 action)\r\n   
at Microsoft.Data.OData.ODataReaderCore.Read()\r\n   
at System.Data.Services.Serializers.EntityDeserializer.ReadEntry(ODataReader odataReader, SegmentInfo topLevelSegmentInfo)\r\n   
at System.Data.Services.Serializers.EntityDeserializer.Read(SegmentInfo segmentInfo)\r\n   
at System.Data.Services.Serializers.ODataMessageReaderDeserializer.Deserialize(SegmentInfo segmentInfo)"}}}
   --- End of inner exception stack trace ---
   at System.Data.Services.Client.SaveResult.HandleResponse()
   at System.Data.Services.Client.BaseSaveResult.EndRequest()
   at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
   at System.Data.Services.Client.DataServiceContext.SaveChanges()
   at Baze.DataEngine.Manager.AdapterForms.ManageNodeForm.btnOK_Click(Object sender, EventArgs e) in C:\Baze.DataEngine\Branches\DataEngine_3.0\Services\DataEngine\Source\Management\Imatis.DataEngine.Manager\AdapterForms\ManageNodeForm.cs:line 79

EF5 service with context derived from DbContext

$
0
0

Okay,  so I'm using entity framework 5.0 and a WCF data service.  I am a little confused because some people are saying that Entity Framework with WCF data services will work out of the box even for database updates and not just reads, I read elsewhere that WCF database services with regular ADO .NET does not do data base update operations out of the box but for Entity Framework they do, but from my understanding of a blog by Rowan Miller about Entity Framework and WCF data services, you need to tweak some things to get it to work if your context derives from DbContext, which mine does.  When I try to do this:

public ObjectContext UnderlyingContext

{ get { return this.ObjectContext; } }

there is no "ObjectContext" in this for my context that derives from DbContext.

Well, I admit I don't have a thorough understanding of what is going on here, that's why I'm asking. Rowen Miller's post is also for CTP4 and I'm using 5.0.

I just want to be able to use my EF 5.0 WCF data servce (custom class deriving from DataService) and be able to do database updates, but I'm unable to get updates to work, only reads.  And my update and savechanges syntax is 100% correct, so I'm thinking that that means that I will have to do some kind of tweak like Miller, except for EF 5.0.

Now I admit possibly the fact that my updates aren't working doesn't have anything to do with the idea that EF and WCF can't do updates out of the box, but that's just a coincidence that mine's not working but I will still have to do a tweak, or maybe I just have a bug or both.

If anyone could help, that would be great.  I will mark any answer as answer.

How to implement EF Code First and WCFDataService

$
0
0

A bit of history first.  I created a EF Code First Library that contains POCO Objects as my Models, a generic DataProvider that inherits from DbContext, generic Repostory that implements the generic DataProvider, and a generic Service that implements the repository.  I have used this library successfully in WPF (MVVM), ASP.Net, Window Forms, and ASP MVC applications.

For this discussion I will reference the Company Model

From the top down, I create a Service class called CompanyService that inherits from a base Service Class.  The CompanyService class contains all of the business logic for the Company Model.  This class uses the Repository class to perform the CRUD operations.  The Repository then encapsulates all the DataProvider class operations.

I have done some research on using EF with WCFDataService, but I can't get my head around how to implement my library with it, particulary when it comes to overriding the CreateDataSource() Method. 

It may be that I should just use a WCF Service instead, maybe I'm not understanding the purpose of the WCFDataService.

I have listed partial code for the classes involved:

	public class CompanyService : ServiceBase<Company> ,ICompanyService
    {
        public Company GetCompanyByFolderId(string eFolderId)
        {
            return (Company)GetModelByFolderId(eFolderId);
        }
	}
    public abstract class ServiceBase<TModel> : IService<TModel> where TModel : class, IModel
    {
        private IDataProvider _dataProvider;
        public IDataProvider DataProvider
        {
            get
            {
                if (_dataProvider == null)
                {
                    string connectionStringName = Properties.Settings.Default.DataProvider;
                    bool enableLazyLoading = true;
                    _dataProvider = new DataProvider(connectionStringName, enableLazyLoading);
                }
                return _dataProvider;
            }
            set
            {
                _dataProvider = value;
            }
        }
        private IRepository<TModel> _repository;
        public IRepository<TModel> Repository
        {
            get
            {
                if (_repository == null)
                {
                    _repository = new Repository<TModel>(DataProvider);
                }
                return _repository;
            }
            set
            {
                _repository = value;
            }
        }
        public TModel GetModelByFolderId(String folderId)
        {
            return GetTable().FirstOrDefault(o => o.EFolderid == folderId);
        }
        public virtual IQueryable<TModel> GetTable()
        {
            return Repository.GetTable();
        }
	}
    public class Repository<TModel> : IRepository<TModel> where TModel : class, IModel
    {
        private IDataProvider _dataProvider;
        public Repository(IDataProvider dataProvider)
        {
            _dataProvider = dataProvider;
        }
        private IDbSet<TModel> DbSet
        {
            get
            {
                return _dataProvider.Set<TModel>();
            }
        }
		public IQueryable<TModel> GetTable()
        {
            return _dataProvider.GetTable<TModel>();
        }
	}
	public class DataProvider : DbContext, IDataProvider 
    {
        public DataProvider()
        {
        }
        public DataProvider(string connectionStringName, bool enableLazyLoading = true)
            : base(connectionStringName)
        {
            Configuration.LazyLoadingEnabled = enableLazyLoading;
            //Configuration.ProxyCreationEnabled = false;
        }
        public new IDbSet<TModel> Set<TModel>() where TModel : class
        {
            return base.Set<TModel>();
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new CompanyMapping());
            base.OnModelCreating(modelBuilder);
        }
        public IQueryable<TModel> GetTable<TModel>() where TModel : class
        {
            return Set<TModel>().AsQueryable();
        }
	}

Then my Test looks something like this:

[TestClass()]
    public class CompanyServiceTest
    {
        [TestMethod()]
        public void GetCompanies()
        {
            CompanyService target = new CompanyService();
            IQueryable<Company> companies = target.GetTable();
            Assert.IsNotNull(companies);
        }
        [TestMethod()]
        public void GetCompanyByFolderId()
        {
            CompanyService target = new CompanyService();
            Company company = target.GetCompanyByFolderId("0000000000000000000000000172403");
            Assert.IsNotNull(company);
        }
	}


Bill Behning

Change tracking issues with WCF Data Services

$
0
0

So I'll admit I'm not in love with the design of this, but I've inherited a problem. I have a wpf application that uses wcf data services as a portion of it's service tier. For a reason unknown to me, they decided to not allow the context to manage change tracking and they do it themselves. So needless to say, everytime they want to update an entity, they do something like this:

Context.AttachTo(entitySetName, entity);

Context.UpdateObject(entity);

Context.SaveChanges();

It's all base classed out very nicely and is loosely coupled, the problem is, it doesn't always work. For instance, if I have say a bank entity, and I change it's phone number and click save this works once beautifully. The changes are pushed to the db and everything is happy. But, if I change that phone number again and click save, it errors out on the attachTo method with a good old:

"The context is already tracking a different entity with the same resource Uri"

Every call to save the entity after the first error gives me this message. This made sense, I just assumed that the entity was there, it was very unhappy about me trying to feed that entity to it again, and I should prevent that. So, with a little research I found this method:

var descriptor = Context.GetEntityDescriptor(entity);
 

Which should give me a bit of information about the state of that entity for the given context. Yet, for both call 1 (which works) and call 2 (which fails with the tracking error), that method returns null. Which according to the documentation means it's not in the context. So I'm at a spot where the context won't let me attach the entity because it believes it has it, yet if I ask it if it's there it tells me no.

Any suggestions would be greatly appreciated!

Thanks everyone,

Ryan

Data service caching issue

$
0
0
Hi

In my VS solution,  I have two projects, one is a Silverlight5 app and the other is a WCF Services app. My Silverlight5 app is hosted on a page in the WCF Services app. In the service app, I added a ADO.NET Entity Data Model, and a WCF data service that maps to this data model. I reference the data service in my Silverlight5 app. This works and I can also query and update my database from the Silverlight5 app using the data service.

The problem that I have is in the Silverlight5 app. For example I have a UserControl called Customers which allows users to add/edit/delete customer records and another called OrdersReports which allows users to select a Customer record from a drop down and then list the orders for that particular customer in a DataGrid below. If the count of orders is zero, it displays "No order to display". In the background of the two user controls, I instantiate a variable _dataService which creates an instance of the data service reference allowing me to communicate with the data service. The user clicks the option to edit customers and loads the Customers UserControl. Data service is instantiated and the user can add, edit and delete records as intended. For example, if the user adds or edits a customer record at that point, everything is saved in the database perfectly. When the user clicks the option for the OrdersReport UserControl, this loads and the data service client is intantiated. The code loads a Customer data service collection with all customer data (to display in drop down) and expands on the Orders node to also bring in the list of orders per customer (to display in data grid). In this case, customers without orders are also retrieved and their Orders property is a empty collection. My problem is that if the user had just added or edited a customer record in the Customers UserControl and even saved these changes, when the OrdersReport UserControl loads, the new or edited customer record is not listed. If I close the app and reopen, then the new and changes are listed.

I would like to find out what is causing this and what is the best method to solve it. Someone has recommended that I instantiate my data service client at the application level and then use it for data service operations everywhere in my app. For sure that works, but this is not efficient because I do not need data service operations everywhere in my app and to leave that object there instantiated when I do not need it is against every rule of good and efficient programming. I think that I am dealing with a cache issue here because the Customers do get saved to the database, but data service calls in OrdersReport seem to be retrieving its data from a cache somewhere. How do I get it to read from the database all the time?

Regards

Terence

JSON.NET convert object but not data.

$
0
0

I have a WCF/REST service returning JSON and I am using JSON.NET to deserialize back to the native object. It does that just fine but the data that is return from the REST call is wiped out after deserialization. Here is the code:

WebClient webClient = new WebClient();
String utf8 = DownloadString(webClient, url, Encoding.UTF8);
var list = JsonConvert.DeserializeObject<MyClass>(utf8);

I don't get what is happening.


WCF Data Services 5 Authentication with datajs

$
0
0

I have an WCF Data Service in .NET and I am consuming this service with datajs in Phonegap. I am trying to implement authentication as decribed here:http://goo.gl/0xQvC, and sending credentials with OData.read method (datajs), but when I read credentials with HttpContext.Current.Request.Headers["Authorization"], I found they are empty. What I am doing wrong?

Service Code:

[ServiceBehavior( IncludeExceptionDetailInFaults = true )]
    public class TeyunaDataService : DataService< Meteora.TeyunaServices.Models.TeyunaContext >
    {
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("Clientes", EntitySetRights.AllRead );
            config.SetEntitySetAccessRule("Transacciones", EntitySetRights.All);

            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            config.UseVerboseErrors = true;
        }

        public TeyunaDataService()
        {
            this.ProcessingPipeline.ProcessingRequest += new EventHandler<DataServiceProcessingPipelineEventArgs>(OnRequest);
        }

        void OnRequest(object sender, DataServiceProcessingPipelineEventArgs e)
        {
            var auth = HttpContext.Current.Request.Headers["Authorization"]; //This is empty
        }
    }
}

Javascript Client code:

OData.read({ requestUri: url, user: "pruebausr", password: "passprb" },    
    function (data, request) {
        // ... code to procesing data (It works fine)

    },  function(err) {
            $.mobile.hidePageLoadingMsg();
            alert("Error al obtener clientes. " + err.message);
    }
);

Service web.config here: https://gist.github.com/3746043

I am using IIS Express.


El servidor remoto devolvió una respuesta inesperada: (413) Request Entity Too Large.

$
0
0
Buenas noches me encuentro con el siguiente error al tratar de guardar o modificar (El servidor remoto devolvió una respuesta inesperada: (413) Request Entity Too Large) soy nuevo en esto y le agradecería a quien pudiera ayudarme.

Stone test qa.social.msdn.microsoft.com

Any update to docs, examples for WCF support of OData annotations?

$
0
0

The recent WCF Data Service 5.3 and 5.4 release notes mentioned improvements in support for OData 3.0 annotations.  However, the only mention I can find of how to access OData annotations in WCF is this "Vocabularies in WCF" article from 2011.

Is this 2 year old article still current/valid and representative of WCF's current access to OData annotations?  Or is there something more recent that reflects WCF developments of the past 2 years? Anything? Please?

Thanks,

-Danny

P.S. My primary interest is how to produce OData annotations in a WCF Data Service that does not use a EDM data model. I've written my own provider for POCOs using the query engine from the WCF Data Toolkit.  Secondary interest is how clients can consume/access those OData annotations using Service Reference generated proxy classes.


http://dannythorpe.com

WCF Data Services Server - Performance issue during projection.

$
0
0

Hi,

I have been working on performance optimizing our custom data service provider. In this proccess I have run into a bottle neck in WCF Data Services Provider (the server part).

The issue is related to GET requests (queries) containing projections (a $select). It seems that for each returned entity the WCF DS server framework will callTryResolvePropertyName on the ResourceType for each property in the projection.

Now - imagine I am returning 10000 entities and projecting 20 properties. This will result in 200000 calls to TryResolvePropertyName. Now if look at the implementation ofTryResolvePropertyName with ILSpy, we'll end up in this...

internal ResourceProperty TryResolvePropertyName(string propertyName, ResourcePropertyKind exceptKind)
{
	return this.Properties.FirstOrDefault((ResourceProperty p) => p.Name == propertyName && (p.Kind & exceptKind) == (ResourcePropertyKind)0);
}
 

If my ResourceType has 200 properties and i am only projecting the 20 last properties in the Properties Collection, this alone takes around 1.2 seconds. In my setup this around 50% of the entire querying processing time on the server - including roundtripping to a database on another machine and getting the response back to the client.

I know you are dedicated to performance (you often state that on the blog), could you please have a look at this.

As a comparison: If the Propertis collection were a Dictionary<srting,ResourceProperty> 200000 lookups could be made in 0.05 seconds.

Another approach would be to only do this havy stuff for the first entity in the feed.

Is there any way to hook into this property resolving stuff, so I can do a more efficient implementation myself?

Btw. This is on WCF Data Services 5.5.0 with a custom provider.

Kind Regards

Uffe


Viewing all 877 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>