Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
WinFS
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Searches=== The WinFS API provides a class called the ''ItemContext'' class, which is bound to a WinFS store. The ''ItemContext'' object can be used to scope the search to the entire store or a subset of it. It also provides [[Transaction (database)|transactional]] access to the store.<ref name="ForDev" /> An object of this class can then spawn an ''ItemSearcher'' object which then takes the type (an object representing the type) of the item to be retrieved or the relationship and the [[#OPath|OPath]] [[Query language|query]] string representing the criteria for the search.<ref name="Dev2" /><ref name="OPath">{{cite web | url = http://msdn2.microsoft.com/en-us/library/aa480689.aspx | title = An Introduction to "WinFS" OPath | date = October 18, 2004 | access-date = 2007-06-30 | author = Thomas Rizzo, Sean Grimaldi | work = MSDN | publisher = Microsoft }}</ref> A set of all matches is returned, which can then be bound to a UI widget for displaying ''en masse'' or enumerating individually.<ref name="MSDNMag" /> The properties items can also be modified and then stored back to the data store to update the data. The ItemContext object is ''closed'' (which marks the end of association of the object with the store) when the queries are made or changes merged into the store. Related items can also be accessed through the items. The ''IncomingRelationships'' and ''OutgoingRelationships'' properties give access to all the set of relationship instances, typed to the name of the relationship. These relationship objects expose the other item via a property. So, for example, if a picture is related to a picture, it can be accessed by ''traversing'' the relationship as: <syntaxhighlight lang="csharp"> ContactsCollection contacts = picture.OutgoingRelationships.Cast(typeof(Contact)).Value; // This retrieves the collection of all outgoing relationships from a picture object // and filters down the contacts reachable from them and retrieves its value. // Or the relationship can be statically specified as ContactsCollection contacts = picture.OutgoingRelationships.OutContactRelationship.Contact; </syntaxhighlight> {{anchor|OPath}} An OPath query string allows to express the parameters that will be queried for to be specified using ''[[#Data storage|Item]]'' properties, embedded ''Items'' as well as ''[[#Data storage|Relationships]]''.{{citation needed|date=January 2015}} It can specify a single search condition, such as ''"title = Something'"'', or a compound condition such as ''"title = 'Title 1' || title = 'Title 2' && author = 'Someone'"''. These Boolean and relational operations can be specified using [[C Sharp (programming language)|C#]] like ''&&'', ''||'', ''='', ''!='' operators as well as their English-like equivalent like ''EQUAL'', ''NOT EQUAL''. [[SQL]] like operators such as ''LIKE'', ''GROUP BY'' and ''ORDER BY'' are also supported, as are wildcard conditions.{{citation needed|date=January 2015}} So, ''"title LIKE 'any*'"'' is a valid query string. These operators can be used to execute complex searches such as <syntaxhighlight lang="csharp"> using (ItemContext ic = ItemContext.Open()) { // Searching begins by creating a ItemSearcher object. The searcher is created from a // relationship instance because the contacts being searched for are in relation. The // first parameter defines the scope of the search. An ItemContext as the scope means // the entire store is to be searched. Scope can be limited to a set of Items which may // be in a holding relationship with the contacts. In that case, the set is passed as // the scope of the search. ItemSearcher searcher = OutContactRelationship.GetTargetSearcher(ic, typeof(Contact)); ContactCollection contacts = searcher.FindAll("OutContactRelationship.Contact.Name LIKE 'A*'"); } </syntaxhighlight> The above code snippet creates an ItemSearcher object that searches on the ''OutContactRelationship'' instance that relates pictures and contacts, in effect searching all pictures related with a contact. It then runs the query ''Name LIKE 'A*'"'' on all contacts reachable through ''OutContactRelationship'', returning the list of ''"contacts whose names start with A and whose pictures I have"''. Similarly, more relationships could be taken into account to further narrow down the results.<ref name="DotNetShow" /><ref name="Dev2" /> Further, a natural language query processor, which parses query in natural language and creates a well-formed OPath query string to search via proper relationships, can allow users to make searches such as ''"find the name of the wine I had with person X last month"'', provided financial management applications are using WinFS to store bills. Different relations specify a different set of data. So when a search is made that encompasses multiple relations, the different sets of data are retrieved individually and a [[Relational algebra|union]] of the different sets is computed. The resulting set contains only those data items that correspond to all the relations.<ref name="Dev2" />
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)