Skip to content

Commit a7a90d0

Browse files
authored
Update ReadMe.md (#76)
This Pull Request changes the language for the usage sample.
1 parent eb088d2 commit a7a90d0

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

ReadMe.md

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,43 +41,44 @@ Use the --version option to specify preview version to install
4141

4242
The following code demonstrates basic usage of DataObjects.Net. For full tutorial configuring Domain, defining the model and querying data see our [documentation](http://help.dataobjects.net).
4343

44-
// create configuration with connection to Tests database on local instance of MS SQL Server
45-
var domainConfiguration = new DomainConfiguration(@"sqlserver://localhost/Tests");
46-
// register types from certain domain
47-
domainConfiguration.Types.Register(typeof (Person).Assembly, typeof (Person).Namespace);
48-
// create database structure from scratch
49-
domainConfiguration.UpgradeMode = DomainUpgradeMode.Recreate;
50-
51-
// on application start build Domain
52-
var domain = Domain.Build(domainConfiguration);
53-
54-
// open a session to database
55-
using (var session = domain.OpenSession()) {
56-
using (var transactionScope = session.OpenTransaction()) {
57-
// query for existing Anton Chekhov
58-
Author existingAuthor = session.Query.All<Author>()
59-
.Where(author => author.FirstName=="Anton" && author.LastName=="Chekhov")
60-
.FirstOrDefault();
61-
62-
//if Anton Pavlovich isn't in database yet then and him
63-
if (existingAuthor==null) {
64-
existingAuthor = new new Author(session) {
65-
FirstName = "Anton",
66-
LastName = "Chekhov";
67-
}
68-
}
69-
70-
// add new book and assign it with Anton Chekhov
71-
existingAuthor.Books.Add(new Book(session) {Title = "The Cherry Orchard"});
72-
73-
// commit opened transaction to save changes made within it
74-
transactionScope.Complete();
44+
```csharp
45+
// create configuration with connection to Tests database on local instance of MS SQL Server
46+
var domainConfiguration = new DomainConfiguration(@"sqlserver://localhost/Tests");
47+
// register types from certain domain
48+
domainConfiguration.Types.Register(typeof (Person).Assembly, typeof (Person).Namespace);
49+
// create database structure from scratch
50+
domainConfiguration.UpgradeMode = DomainUpgradeMode.Recreate;
51+
52+
// on application start build Domain
53+
var domain = Domain.Build(domainConfiguration);
54+
55+
// open a session to database
56+
using (var session = domain.OpenSession()) {
57+
using (var transactionScope = session.OpenTransaction()) {
58+
// query for existing Anton Chekhov
59+
Author existingAuthor = session.Query.All<Author>()
60+
.Where(author => author.FirstName=="Anton" && author.LastName=="Chekhov")
61+
.FirstOrDefault();
62+
63+
//if Anton Pavlovich isn't in database yet then and him
64+
if (existingAuthor==null) {
65+
existingAuthor = new new Author(session) {
66+
FirstName = "Anton",
67+
LastName = "Chekhov";
7568
}
7669
}
7770

78-
// on application shutdown dispose existing domain
79-
domain.Dispose()
71+
// add new book and assign it with Anton Chekhov
72+
existingAuthor.Books.Add(new Book(session) {Title = "The Cherry Orchard"});
8073

74+
// commit opened transaction to save changes made within it
75+
transactionScope.Complete();
76+
}
77+
}
78+
79+
// on application shutdown dispose existing domain
80+
domain.Dispose()
81+
```
8182

8283

8384
### Getting support
@@ -110,4 +111,4 @@ Version.props file declares version is building. `<DoVersion>` tag defiles versi
110111

111112
### License
112113

113-
DataObjects.Net and its extensions published here are licensed under the [MIT](https://github.com/DataObjects-NET/dataobjects-net/blob/master/License.txt) license.
114+
DataObjects.Net and its extensions published here are licensed under the [MIT](https://github.com/DataObjects-NET/dataobjects-net/blob/master/License.txt) license.

0 commit comments

Comments
 (0)