Wednesday, July 8, 2020

ef core tips



 Debug code-first Entity Framework migration codes
 Place this piece of code right above the migration you want to debug:
  if (!System.Diagnostics.Debugger.IsAttached)
            System.Diagnostics.Debugger.Launch();
More details / Ref  : https://stackoverflow.com/a/52700520/193061

Thursday, July 2, 2020

Powershell TitBits




Replace all file names in a folder

Get-ChildItem -Filter “*ModelMap*” -Recurse | Rename-Item -NewName {$_.name -replace ‘ModelMap’ ,’ModelMapping’ }

Thursday, June 4, 2020

Java To C# mapping





   Java          C#

   Map      Dictionary
   Set      HashSet
   Pair      KeyValuePair 
   .map              .Select       
   .collect          .ToList()
   .stream           .AsEnumerable 
   LinkedHashSet     <Need custom impl >
   flatMap()         SelectMany
   format()      String.format()
   zip( .Zip(
   joining() String.Join(
   InstStream(1,100)  Enumerable.Range(1, 100)
   Function    Func 
   .apply(           .Invoke(
   .isEmpty()   .Any()
   .size()   .Count
   .filter(           .Where(
   BiFunction    Func
   

Wednesday, August 9, 2017

using Linq methods with caution - E.g FirstorDefault()


Don't use FirstorDefault() unless you are sure its valid/ verified in the business scenario. else you are going to introduce bugs in the code.


Saturday, April 15, 2017

Git tips


Set up Git

Removing non-repository files with git?

--------------------------------------------------------------------------------------------------------------

How do I discard unstaged changes in Git?

Ans: 
a)For a specific file use:
git checkout path/to/file/to/revert
b)For all unstaged files use:
git checkout -- .
Make sure to include the period at the end.
c)To check out specific files
git checkout -- cats.html index.html
---------------------------------------------------------------------------------------------------------------------
git branch -a                                     -- lists all branches
git push origin :branchnamehere     -- to delete the remote branch(note semicolin before                                                                                    branchname)

git remote show origin                     -- checks for stale branches tracking origin
git remote prune origin                     -- to clean up deleted remote branches

git tag                                                           -- list all tags
git tag -a v0.1.2.3 -m "versioncomments"   -- add a new tag
git push --tags                                              -- to push new tags


---------------------------------------------------------------------------------------------------------------------
git fetch      -- pulls down the history but does not merge

rebase vs Merge
Rule of thumb:
1. When pulling changes from origin/develop onto your local develop use rebase.
          git pull --rebase

2. When finishing a feature branch merge the changes back to develop.

---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------


---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



Devops links

  Build Versioning in Azure DevOps Pipelines