The primary mode of data retrieval from a WinFS store is querying the WinFS store according to some criteria, The data in them can be accessed by accessing the properties of individual objects. A set of all matches is returned, which can then be bound to a UI widget for displaying
en masse or enumerating individually. 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: 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; An OPath query string allows to express the parameters that will be queried for to be specified using
Item properties, embedded
Items as well as
Relationships. 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# 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. So, "title LIKE 'any*'"'' is a valid query string. These operators can be used to execute complex searches such as 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*'"); } 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. 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
union of the different sets is computed. The resulting set contains only those data items that correspond to all the relations.
Notifications WinFS includes better support for handling data that changes frequently. Using WinFS
Notifications, applications choose to be notified of changes to selected data
Items. WinFS will raise an
ItemChangedEvent, using the .NET Event model, when a subscribed-to Item changes, and the event will be published to the applications.
Information Agent WinFS includes an Information Agent feature for the management, retrieval, and storage of end-user notification rules and preferences for changes to items in the data store. Using Information Agent, it is possible to automatically define relations to new items based on events such as appointments, with an example being that appointments can be related to photos based on the dates the photos were taken, enabling queries for birthdays or holidays without needing to know the actual dates of such events ("
find all photos taken on this birthday"). Other examples include automatically moving new items to specific folders based on a rule as determined by appointment times and dates the photos were taken ("
when I import a photo taken during a business event, move it to the Business Events folder") or more complex possibilities. Information Agent can also forward notifications to other devices ("
if I receive a high priority email from my boss, send a notification to my phone") and is similar to Rules and Alerts functionality of Microsoft Outlook. ==Data sharing==