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 same hashtag may appear in more than one tweet, and so the collection of Tweets is marked with the ‘Inverse Property’ attribute to show that it is the other end of the collection of Hash Tags in the ITweet interface: var trevor = context. We can also add other attributes such as those from the namespace to provide additional hints for the MVC framework such as marking a property as required, providing an alternative display name for forms or specifying the way in which a property should be rendered.
The basic MVC4 template for these operations makes a couple of assumptions that we need to correct.
Firstly, the id parameter passed in to various operations is assumed to be an int; however our Brightstar DB entities use a string value for their Id, so we must change the int id parameters to string id on the Details, Edit and Delete actions.
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.
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.
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.
Any time you modify the interfaces that define your data model, you should re-run the text template to regenerate the context code.
NET MVC4 for the CRUD application and Brightstar DB for data storage. NET MVC 4 Web Application” from the list of project types in Visual Studio.
NET MVC, we will use the well-known “Nerd Dinner” tutorial used by . We won’t recreate the full Nerd Dinner application, but just a portion of it, to show how to use Brightstar DB for code-first data persistence, and show how it not only matches the ease of creating applications from scratch, but surpasses Entity Framework by introducing pain free model changes (more on that later). Nerd Dinner sample application shows a simple model layer, using ASP.
You must also install the “Visual Web Developer” feature in Visual Studio to be able to open and work with MVC projects. In the next dialog box, select “Empty” for the template type, this mean that the project will not be pre-filled with any default controllers, models or views so we can show every step in building the application. Leave the “Create a unit test project” box unchecked, as for the purposes of this example project it is not needed.