The ‘Following’ property shows the list of users that this user follows, the other end of this relationship is shown in the ‘Followers’ property, this is marked with the ‘Inverse Property’ attribute to tell Brightstar DB that Followers is the other end of the Following relationship. In order to work with simpler values for our entity Ids we decorate the Id property with an identifier attribute.The final property is a list of tweets that the user has authored, this is the other end of the relationship from the ITweet interface (described below): ITweet The ITweet interface represents a tweet on twitter, and has simple properties for the tweet content and the date and time it was published. This adds a prefix for Brightstar DB to use when generating and querying the entity identifiers and ensures that the actual value we get in the Id property is just the part of the URI that follows the prefix, which will be a simple GUID string.As with the previous method, the type of the id parameter has been changed to string: The method that accept the Http Post that is sent back after a user clicks “Save” on the view, deals with updating the property values in the store.Note that rather than receiving the id and Forms Collection parameters provided by the default scaffolding, we change this method to receive a Dinner object.The Tweet Box sample is a simple console application that shows the speed in which Brightstar DB can load content. The only thing you will need to ensure is that if you are using an HTTP, TCP or Named Pipe connection, the Brightstar DB service must be running: New Item on the Models folder, and select Brightstar Entity Context from the Data category.The aim is not to create a Twitter style application, but to show how objects with various relationships to one another are loading quickly, in a structure that will be familiar to developers. The relationships between the interfaces mimic the structure on Twitter, in that Users have a many to many relationship with other Users (or followers), and have a one to many relationship with Tweets. Rename it to Nerd Dinner Step 5: Creating the data model interfaces Brightstar DB data models are defined by a number of standard . The Nerd Dinner model is very simple (especially for this tutorial) and only consists of a set of “Dinners” that refer to specific events that people can attend, and also a set of “RSVP”s that are used to track a person’s interest in attending a dinner.The Tweet has an IUser property (‘Author’) to relate it to the user who wrote it (the other end of this relationship is described above). In the IRSVP interface, we add an Inverse Property attribute to the Dinner property, and set it to the name of the . This shows that these two properties reflect different sides of the same association.ITweet also contains a collection of Hashtags that appear in the tweet (described below): IHash Tag A hashtag is a keyword that is contained in a tweet. In this case the association is a one-to-many relationship (one dinner can have many RSVPs), but Brightstar DB also supports many-to-many and many-to-one relationships using the same mechanism.
In this section we will start to flesh out the MVC application with some screens for data entry and display. Name it “Home Controller” and select “Controller with empty Read/Write Actions”.
Index This view will show a list of all dinners in the system, it’s a simple case of using LINQ to return a list of all dinners:: Details This view shows all the details of a particular dinner, so we use LINQ again to query the store for a dinner with a particular Id.
Note that we have changed the type of the id parameter from int to string.
The LINQ query here uses First Or Default() which means that if there is no dinner with the specified ID, we will get a null value returned by the query.
If that is the case, we return the user to a “404” view to display a “Not found” message in the browser, otherwise we return the default Details view.: Edit The controller has two methods to deal with the Edit action, the first handles a get request and is similar to the Details method above, but the view loads the property values into a form ready to be edited.
This runs the text templating tool that updates the file contained within the file with the most up to date persistence code needed for your interfaces.