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

Can't make 'Expand' work on WCF Data Service

$
0
0

Hello.

I'm trying to develop a simple WCF Data Service, using EntityFramework code first. The problem is that I can't make the 'Expand' work, nor in the web browser or .NET client, althought the data is related in the database.

This are the two entities:

[Table("MaterialesBase")]
[DataServiceKey("ReferenciaBase")]
public class MaterialBase
{
[Key]
public string ReferenciaBase { get; set; }
public Guid MakerId { get; set; }
}

[Table("Perfiles")]
[DataServiceKey("ReferenciaBase")]
public class Perfil
{
[Key]
public string ReferenciaBase { get; set; }

[ForeignKey("ReferenciaBase")]
public MaterialBase MaterialBase { get; set; }

public float? Altura { get; set; }

};

When I try to use expand on web browser, I get the data for 'Perfil' object, but data for 'MaterialBase' is empty:

<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?><entry xml:base="https://scrum.prefnet.net/Preference.Data.Service/DataService.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"><id>https://scrum.prefnet.net/Preference.Data.Service/DataService.svc/Perfiles('PPV-101-208%20%20%20%20%20%20%20%20%20%20%20%20%20%20')</id><title type="text"></title><updated>2012-11-21T13:25:58Z</updated><author><name /></author><link rel="edit" title="Perfil" href="Perfiles('PPV-101-208%20%20%20%20%20%20%20%20%20%20%20%20%20%20')" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/MaterialBase" type="application/atom+xml;type=entry" title="MaterialBase" href="Perfiles('PPV-101-208%20%20%20%20%20%20%20%20%20%20%20%20%20%20')/MaterialBase"><m:inline /></link><category term="Preference.Data.Service.Model.Perfil" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><content type="application/xml"><m:properties><d:ReferenciaBase xml:space="preserve">PPV-101-208              </d:ReferenciaBase><d:Altura m:type="Edm.Single">70</d:Altura></m:properties></content></entry>

Also, when I try to use on a .NET client, I get same result. See the code:

var query = from p in data.Profiles.Expand (p=>p.BaseMaterial)
where p.BaseReference == "PPV-101-208"
select p;
var profile = query.SingleOrDefault();

Profile has data but the reference to MaterialBase is NULL. However, if I add this the data is loaded:

data.LoadProperty(profile, "BaseMaterial");

But this is not what I want, because I have to do make two service calls.  

Any ideas of what I'm doing wrong?

Thanks.


Viewing all articles
Browse latest Browse all 877

Trending Articles



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