Software craftsmenship manifesto

From Creaftsmenship Manifesto

Background materials

Food for thought

Kata and exercises

Conferences and community

Get all documents from mongodb collection

Get all documents from a MongoDB collection:

Using the current version of the driver (v2.0) you can do that by passing a filter that matches everything:

var documents = await SpeCollection.Find(_ => true).ToListAsync();

They have also added an empty filter (FilterDefinition.Empty) which will arrive in the next version of the driver (v2.1):

var documents = await SpeCollection.Find(Builders.Filter.Empty).ToListAsync();

With and without Lambda Expression

var id = 1;
var query =
from user in database.Users
join invoice in database.Invoices on user.Id equals invoice.UserId
where user.Id == id
select new { User = user, Invoice = invoice };

Here’s the same query, using Lambda Expression LINQ extension methods:

var id = 1;
var query = database.Users // your starting point - table in the "from" statement
.Join(database.Invoices, // the source table of the inner join
user => user.Id, // Select the primary key (the first part of the "on" clause in an sql "join" statement)
invoice => invoice.UserId, // Select the foreign key (the second part of the "on" clause)
(user, invoice) => new { User = user, Invoice = invoice }) // selection
.Where(userAndInvoice => userAndInvoice.User.Id == id); // where statement

Git workflow

Here you can see the basics workflow for git
After cloning your repo from any git platform provider Like github, gitlab, bitbucket etc… .
Firstly check branch:
git branch
(your base branch, most likely develop or master. Consider develop as a base branch)
Fetch latest remote code to local:
git pull
(for latest develop code)
Checkout new branch as per feature and
git checkout -b newBranchName
(If you are working on any new bug named branch feature than give branch name feature/ login-feature or you are working on any bug than give branch name bug/login-bug.
This way you can eaisily identify/judge your branch by name.)

After finish your work in your
$ git status (after Changes )
Add changed file into staging
git add . | | $ git add .. (dot) (for feature/bug branch.(in red colored) add file in staging)
Check staging file (in green colored)
$ git status
Add commit message
$ git commit -m Commit message
Checkout your base branch
$ git checkout develop (switch
For latest code (if other guy
$ git pull (for latest develop code)
Checkout your previous feature/to develop) working on it)
bug branch

git pull (for latest develop code)
Checkout your previous feature.
git checkout YOUR PREVIOUS_BRANCH
Rebase your branch with develop
git rebase develop
Push your feature/bug branch
git push
(it will suggest command if bug branch or master to remote: its not in remote).
After this open your git platform provider Like github, gitlab, bitbucket whatever you use.
Assign merge request to your other develop to review code, it will increase your productivity and code quality.

Git update and publish

git remote -v
git remote show
git remote add
git fetch
git fetch --all
git pull | git pull
git push
git push
git push origin :old-name new-name
git push origin -u new-name
git branch -dr
git push origin YourTagVersion

Git local changes

git status
Changes files in your working directory
git diff
Changes to tracked files
git diff <filename|filepath>
Show or list our the changes of specific file as per comparison to previous commit
git add . | git add ..
Add all current changes to the next commit
git add FILENAME
Add particular file changes to the next commit
git add -p
git commit
git commit -m 'Commit description'
git commit -a
git commit --amend
git commit --amend -m "an updated commit message"
git commit --amend --no-edit