Cannot filter by string from remote url - rest

Created a WCF Data Service to pull data from Oracle database and when debugging in VS I can use the ?$filter syntax to filter returned sets.
However, using the remote url I cannot.
Point to note: I can filter by integers and dates, however I cannot filter by strings.
Also, I cannot filter by any string field in code. The filter is ignored.
Sample item below:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://localhost:61905/CampaignerSVC.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">
<title type="text">Contacts</title>
<id>http://localhost:61905/CampaignerSVC.svc/Contacts</id>
<updated>2015-04-29T15:06:48Z</updated>
<link rel="self" title="Contacts" href="Contacts" />
<entry>
<id>http://localhost:61905/CampaignerSVC.svc/Contacts(23517014)</id>
<title type="text"></title>
<updated>2015-04-29T15:06:48Z</updated>
<author>
<name />
</author>
<link rel="edit" title="ContactList" href="Contacts(23517014)" />
<category term="Campaigner_DAL_WCF.ContactList" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:LicenseNumber m:type="Edm.Int32">23517014</d:LicenseNumber>
<d:ClientCode>2000</d:ClientCode>
<d:ClientName>Doodler</d:ClientName>
<d:ClientMnemonic>DD</d:ClientMnemonic>
<d:LastName>Kerr</d:LastName>
<d:FirstName>Rover</d:FirstName>
<d:MiddleName>Frank</d:MiddleName>
<d:Title>Mr.</d:Title>
<d:PreferredFirstName>Rover</d:PreferredFirstName>
<d:PreferredMiddleName>Frank</d:PreferredMiddleName>
<d:CompanyName m:null="true" />
<d:JobTitle m:null="true" />
<d:Gender>M</d:Gender>
<d:DateOfBirth m:type="Edm.DateTime">1947-04-27T00:00:00</d:DateOfBirth>
<d:PrimaryChapterCode m:type="Edm.Int16">400</d:PrimaryChapterCode>
<d:AlternateChapterCode m:type="Edm.Int16" m:null="true" />
<d:MainAddrStreetNo>121</d:MainAddrStreetNo>
<d:MainAddrLine1>So Crescent</d:MainAddrLine1>
<d:MainAddrLine2 m:null="true" />
<d:MainAddrLine3 m:null="true" />
<d:MainAddrCity>MAICK</d:MainAddrCity>
<d:MainAddrProvCode>ON</d:MainAddrProvCode>
<d:MainAddrProv>Ontario</d:MainAddrProv>
<d:MainAddrPostalCode>KB7</d:MainAddrPostalCode>
<d:MainAddrCountryCode>CA</d:MainAddrCountryCode>
<d:MainAddrCountry>Canada</d:MainAddrCountry>
<d:MainPhoneNum>610-000-0703</d:MainPhoneNum>
<d:MainPhoneExt m:null="true" />
<d:MainFaxNum m:null="true" />
<d:MainEmailAddr>someone#rogers.com</d:MainEmailAddr>
<d:CellPhoneNum m:null="true" />
<d:ChangeType>D</d:ChangeType>
<d:EventTimeStamp m:type="Edm.DateTime">2015-04-29T02:40:02</d:EventTimeStamp>
<d:PrivacyIndicator>N</d:PrivacyIndicator>
</m:properties>
</content>
</entry>
</feed>

You can filter by string also by using the string in quotes like below-
'string'

Ok, so the issue was that I had created a class to store the results from the entity model.
Although I had a DataKey value specified, the problem was that the field I specified was not unique, therefore the filters were being ignore (or only the first matching record was filtered).
What I had to do was decorate the class with a composite DataKey.

Related

OpenXML stylesheet corruption

I'm getting an error on this (formatted for readability) OpenXML stylesheet at column 153, which seems to be the '.' in the 0.0% format identifier. Can anyone see what is wrong here? If I remove the numFmts then the issue goes away.
<?xml version="1.0" encoding="utf-16"?>
<x:styleSheet xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<x:numFmts count="2">
<x:numFmt />
<x:numFmt numFmtId="164" formatCode="0.0%" />
</x:numFmts>
<x:fonts count="2">
<x:font>
<x:sz val="11" />
<x:color rgb="000000" />
<x:name val="Calibri" />
</x:font>
<x:font>
<x:b />
<x:sz val="11" />
<x:color rgb="000000" />
<x:name val="Calibri" />
</x:font>
</x:fonts>
<x:fills count="1">
<x:fill>
<x:patternFill patternType="none" />
</x:fill>
</x:fills>
<x:borders count="1">
<x:border>
<x:left />
<x:right />
<x:top />
<x:bottom />
<x:diagonal />
</x:border>
</x:borders>
<x:cellXfs count="3">
<x:xf />
<x:xf fontId="1" applyFont="1" />
<x:xf numFmtId="164" applyNumberFormat="1" />
</x:cellXfs>
</x:styleSheet>
It's the empty <x:numFmt> element in the line above that's the cause of the issue. The numFmtId and formatCode are required elements within that element.
The schema from ECMA is:
<xsd:complexType name="CT_NumFmt">
<xsd:attribute name="numFmtId" type="ST_NumFmtId" use="required"/>
<xsd:attribute name="formatCode" type="s:ST_Xstring" use="required"/>
</xsd:complexType>
It's worth trying the OpenXml Productivity Tool in situations like these. It will validate files as well as backwards engineer code from a valid file. In your case you'd get something like this:

DGML - Add weight to link

How do I add weight or value to the Edges or Link in a DGML file?
<?xml version='1.0' encoding='utf-8'?>
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="a" Label="a" Size="10" />
<Node Id="b" Background="#FF008080" Label="b" />
<Node Id="c" Label="c" Start="2010-06-10" />
</Nodes>
<Links>
<Link Source="a" Target="b" />
<Link Source="a" Target="c" />
</Links>
<Properties>
<Property Id="Background" Label="Background" DataType="Brush" />
<Property Id="Label" Label="Label" DataType="String" />
<Property Id="Size" DataType="String" />
<Property Id="Start" DataType="DateTime" />
</Properties>
</DirectedGraph>
I would like to be able to assign a weight or value to the lines between each node to designate the strength between the nodes.
You can add weights to each link by adding a label field with a value to each of the Link Sources. The numbers will appear beside the arrows on your graph.
<Link Source="a" Target="b" Label="5" />
<Link Source="a" Target="c" Label="6" />
Additionally, the background color of each node can be changed by creating Category groups and assigning that group to each node.
<Category Id="Orange" Background="Orange" />
<Category Id="Yellow" Background="Yellow" />
<Node Id="a" Category="Orange" />
<Node Id="b" Category="Yellow" />
Here's an example that uses a link Weight Style to do it:
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="Banana" UseManualLocation="True" />
<Node Id="Test" UseManualLocation="True" />
</Nodes>
<Links>
<Link Source="Test" Target="Banana" Priority="10"/>
<Link Source="Test" Target="Green" />
</Links>
<Properties>
<Property Id="Bounds" DataType="System.Windows.Rect" />
<Property Id="UseManualLocation" DataType="System.Boolean" />
</Properties>
<Styles>
<Style TargetType="Link">
<Setter Property="Weight" Expression="Priority" />
</Style>
</Styles>
</DirectedGraph>

Orchard cms adding data-mediapicker-uploadpath to a custom type

I have created a custom type in orchard cms, that has a two column lay out
It has 2 header text fileds and 2 content HTML flavour fileds
Heres the migration :
public class MigrationTwoColumnPageType : DataMigrationImpl
{
public int Create()
{
// Define the project type
ContentDefinitionManager.AlterTypeDefinition("TwoColumnPage", cfg => cfg
.WithSetting("Stereotype", "Content")
.CommomPart()
.AutoroutePart()
.WithPart("TitlePart")
.WithPart("MenuPart")
.WithPart("TagsPart")
.WithPart("PublishLaterPart")
.WithPart("TwoColumnPage")
.Creatable()
.Draftable());
return 1;
}
public int UpdateFrom1()
{
// Define project part - having a part with the same name will create fields in the project type
ContentDefinitionManager.AlterPartDefinition("TwoColumnPage", builder => builder
.TextField("Column1Title", Flavour.Large)
.TextField("Column1Text", Flavour.Html)
.TextField("Column2Title", Flavour.Large)
.TextField("Column2Text", Flavour.Html)
.Attachable());
return 2;
}
}
NOTE: TextField is a custom extension method to make things less verbose
When I try and use the media picker to up load an image into one of these content fields I get a folder not found error, - I have traced this back to the media path on the Request querystring not being set
// media directory to save uploaded files into
var mediaPath = Request["uploadpath"];
in ../../Orchard.MediaPicker/Views/admin/Tab_Url.cshtml
Is there some way to set this using filed settings ?
Seems to work fine for any pages I create, but custom types .... how do I set this value ?
UPDATE
Heres the xml meta data for a page...
<!--Exported from Orchard-->
<Orchard>
<Recipe>
<Name>Generated by Orchard.ImportExport</Name>
<Author>admin</Author>
</Recipe>
<Metadata>
<Types>
<Page ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" TypeIndexing.Included="true" DisplayName="Page">
<NavigationPart />
<CommonPart DateEditorSettings.ShowDateEditor="true" />
<PublishLaterPart />
<TitlePart />
<AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-page'}]" AutorouteSettings.DefaultPatternIndex="0" />
<BodyPart />
<TagsPart />
<LocalizationPart />
</Page>
</Types>
<Parts>
<NavigationPart ContentPartSettings.Attachable="True" />
<CommonPart ContentPartSettings.Attachable="True" />
<PublishLaterPart ContentPartSettings.Attachable="True" />
<TitlePart ContentPartSettings.Attachable="True" />
<AutoroutePart ContentPartSettings.Attachable="True" />
<BodyPart ContentPartSettings.Attachable="True" BodyPartSettings.FlavorDefault="html" />
<TagsPart ContentPartSettings.Attachable="True" />
<LocalizationPart />
</Parts>
</Metadata>
</Orchard>
Here's the XML meta for my custom type, using TestFiledSetting instead of BodyPartSetting
<!--Exported from Orchard-->
<Orchard>
<Recipe>
<Name>Generated by Orchard.ImportExport</Name>
<Author>admin</Author>
</Recipe>
<Metadata>
<Types>
<TwoColumnPage Stereotype="Content" OwnerEditorSettings.ShowOwnerEditor="false" ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" DisplayName="Two Column Page">
<CommonPart />
<AutoroutePart AutorouteSettings.PatternDefinitions="[{Name:'/Title', Pattern: '/{Content.Slug}', Description: 'my-page'}]" />
<TitlePart />
<MenuPart />
<TagsPart />
<PublishLaterPart />
<TwoColumnPage />
</TwoColumnPage>
</Types>
<Parts>
<CommonPart ContentPartSettings.Attachable="True" />
<AutoroutePart ContentPartSettings.Attachable="True" />
<TitlePart ContentPartSettings.Attachable="True" />
<MenuPart ContentPartSettings.Attachable="True" />
<TagsPart ContentPartSettings.Attachable="True" />
<PublishLaterPart ContentPartSettings.Attachable="True" />
<TwoColumnPage ContentPartSettings.Attachable="True">
<Column1Title.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Large" TextFieldSettings.Hint="" />
<Column1Text.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Html" TextFieldSettings.Hint="" />
<Column2Title.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Large" TextFieldSettings.Hint="" />
<Column2Text.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Html" TextFieldSettings.Hint="" />
</TwoColumnPage>
</Parts>
</Metadata>
</Orchard>
No mention of data-mediapicker-uploadpath in either. I'm still lost!

Do I have to use XML parsing or any other way of saving the server response

I am getting the following response from server:
<?xml version="1.0" encoding="UTF-8"?>
<tracks type="array">
<track>
<id type="integer">13082503</id>
<created-at type="datetime">2011-04-05T05:48:05Z</created-at>
<user-id type="integer">2796383</user-id>
<duration type="integer">6715</duration>
<commentable type="boolean">true</commentable>
<state>finished</state>
<sharing>public</sharing>
<tag-list />
<permalink>myfirstsong-tutorial1-6</permalink>
<description nil="true" />
<streamable type="boolean">true</streamable>
<downloadable type="boolean">false</downloadable>
<genre nil="true" />
<release nil="true" />
<purchase-url nil="true" />
<label-id nil="true" />
<label-name nil="true" />
<isrc nil="true" />
<video-url nil="true" />
<track-type nil="true" />
<key-signature nil="true" />
<bpm nil="true" />
<title>MyFirstSong-Tutorial1</title>
<release-year nil="true" />
<release-month nil="true" />
<release-day nil="true" />
<original-format>m4a</original-format>
<license>all-rights-reserved</license>
<uri>http://api.soundcloud.com/tracks/13082503</uri>
<permalink-url>http://soundcloud.com/sleuth007/myfirstsong-tutorial1-6</permalink-url>
<artwork-url nil="true" />
<waveform-url>http://w1.sndcdn.com/8MqNbtkeyhNZ_m.png</waveform-url>
<user>
<id type="integer">2796383</id>
<permalink>sleuth007</permalink>
<username>sleuth007</username>
<uri>http://api.soundcloud.com/users/2796383</uri>
<permalink-url>http://soundcloud.com/sleuth007</permalink-url>
<avatar-url>http://a1.sndcdn.com/images/default_avatar_large.png?5fb6c47</avatar-url>
</user>
<stream-url>http://api.soundcloud.com/tracks/13082503/stream</stream-url>
<downloads-remaining type="integer">100</downloads-remaining>
<secret-token>s-5vz60</secret-token>
<secret-uri>http://api.soundcloud.com/tracks/13082503?secret_token=s-5vz60</secret-uri>
<user-playback-count type="integer">1</user-playback-count>
<user-favorite type="boolean">false</user-favorite>
<playback-count type="integer">0</playback-count>
<download-count type="integer">0</download-count>
<favoritings-count type="integer">0</favoritings-count>
<comment-count type="integer">0</comment-count>
<created-with>
<id type="integer">61</id>
<name>Cocoa API Wrapper Test</name>
<uri>http://api.soundcloud.com/apps/61</uri>
<permalink-url>http://soundcloud.com/apps/cocoa-api-wrapper-test</permalink-url>
</created-with>
<attachments-uri>http://api.soundcloud.com/tracks/13082503/attachments</attachments-uri>
</track>
</tracks>
Do I have to do XML parsing for this or is there any other way to save this as array
You will have to use NSXMLParser for parsing the xml file. "type=array" is XML attribute and not an array.

How do I return an Entity Framework Entity from a WCF Data Service Webget?

I'm trying to return a simple object (that was created in an EDMX with EF 4) through a WebGet operation in my WCF Data Service. I'm able to see the object, but the property that is an object is not populated (int this Case DisplaySize is empty, even though I've set it. I'm planning on making a database call to populate this from a non-EF generated table because we haven't migrated all the data to the new schema yet. (please infer the object types from this)
[WebGet]
[SingleResultAttribute]
public Display GetDisplay(int displayId)
{
Display foundDisplay = new Display();
foundDisplay.DisplaySize = new DisplaySize() { Id = 1, Width = 1024, Height = 768, Dimensions = "1024 X 768" };
foundDisplay.Id = displayId;
return foundDisplay;
}
the url call I'm using: http://localhost:1354/services/EDMDataService.svc/GetDisplay?displayId=1
The xml from the call is:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="http://localhost:1354/services/EDMDataService.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>http://localhost:1354/services/EDMDataService.svc/Displays(1)</id>
<title type="text"></title>
<updated>2010-11-12T19:34:29Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Display" href="Displays(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/DisplaySize" type="application/atom+xml;type=entry" title="DisplaySize" href="Displays(1)/DisplaySize" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Address" type="application/atom+xml;type=entry" title="Address" href="Displays(1)/Address" />
<category term="DataModels.Display" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:DisplaySizeID m:type="Edm.Int32">0</d:DisplaySizeID>
<d:DisplayTypeID m:type="Edm.Int32">0</d:DisplayTypeID>
<d:TimeZoneID m:type="Edm.Int32" m:null="true" />
<d:Facing m:null="true" />
<d:PanelNumber m:type="Edm.Int32" m:null="true" />
<d:DisplayTemplateTypeID m:type="Edm.Int32">1</d:DisplayTemplateTypeID>
<d:DisplayGUID m:null="true" />
<d:RegistrationKey m:null="true" />
<d:FirmwareVersion m:null="true" />
<d:Id m:type="Edm.Int32">1</d:Id>
<d:Base m:type="DataModels.Base">
<d:Title>test</d:Title>
<d:Summary>Description would go here</d:Summary>
<d:DataCenterSiteID m:type="Edm.Int32">0</d:DataCenterSiteID>
</d:Base>
</m:properties>
</content>
</entry>
Just add &$expand=DisplaySize to your URL, and the response will contain the expanded entity as well.