Monday, December 14, 2020

how to find the table name using column name in mysql

 SELECT DISTINCT TABLE_NAME 

FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('columnA','ColumnB')
AND TABLE_SCHEMA='YourDatabase';

Wednesday, December 2, 2020

linq error At least one object must implement IComparable

 Well, you're trying to use SortedSet<>... which means you care about the ordering. But by the sounds of it your Player type doesn't implement IComparable<Player>. So what sort order would you expect to see?

Basically, you need to tell your Player code how to compare one player with another. Alternatively, you could implement IComparer<Player> somewhere else, and pass that comparison into the constructor of SortedSet<> to indicate what order you want the players in. For example, you could have:

public class PlayerNameComparer : IComparer<Player>
{
    public int Compare(Player x, Player y)
    {
        // TODO: Handle x or y being null, or them not having names
        return x.Name.CompareTo(y.Name);
    }
}

Then:

// Note name change to follow conventions, and also to remove the
// implication that it's a list when it's actually a set...
SortedSet<Player> players = new SortedSet<Player>(new PlayerNameComparer());

linq orderby collection property

 IQueryable<Parent> data = context.Parents.OrderBy(p=>p.Children.OrderBy(chi => chi.Name).FirstOrDefault());

Tuesday, December 1, 2020

How to execute sql queries in workbench mysql ?

 If you are from MS SQL background and first time working with MySql , you may be struggling for finding the shortcut key to execute the sql query in workbench. 


Here is the short cut to execute the SQL query in workbench MySql. 

Default key mapping
  1. Execute (All or Selection) -> Ctrl + Shift + Enter.
  2. Execute Current Statement -> Ctrl + Enter.

Saturday, November 28, 2020

How to assign property value while initializing class in typescript

 While creating new object you want to set the value of few fields of class , then you can use following feature of typescript to do that : 


class Person {
    public name: string = "default"
    public address: string = "default"
    public age: number = 0;

    public constructor(init?:Partial<Person>) {
        Object.assign(this, init);
    }
}

let persons = [
    new Person(),
    new Person({}),
    new Person({name:"John"}),
    new Person({address:"Earth"}),    
    new Person({age:20, address:"Earth", name:"John"}),
];


Saturday, November 21, 2020

How to make sure application always run with admin access

 Most of the time it happen with programmer , that they forget to run the application (Visual Studio/VS Code or any other IDE) with admin access. Because of that in result they face weird errors. So instead of every time facing same issue again and again, we can set the application permission in such way that its always run with admin access. 


Here are the steps which you can use to make sure your application always run with admin access. 


how to make sure application always run with admin access


        1. Open Start.
        2. Search for the app that you want to run elevated.
        3. Right-click the top result, and select Open file location. ...
        4. Right-click the app shortcut and select Properties.
        5. Click on the Shortcut tab.
        6. Click the Advanced button.
        7. Check the Run as administrator option.

Tuesday, November 17, 2020

How to find the angular component name ?

 

Use ng.probe($0).componentInstance

You can select a component using the Element Selector from the Elements Tab. And then go to the Console Tab, and type in:

ng.probe($0).componentInstance

Saturday, October 31, 2020

Where to find the files after ng build in angular

Once you run the ng build --prod for deployment build and you are wondering after successfully from where to copy files to deployment. 

You can check path on following setting where its mentioned in angular.json file. 

"outDir": "./location/toYour/dist"

Monday, October 26, 2020

How to remove all elements from JavaScript Array ?

 In case you have an array in JavaScript and you want to remove all elements from that array , there are couple of ways by which you can remove all elements from your array. 


#1 

Arr = [];
#2 

 Arr.length = 0

#3 
 
 Arr.splice(0,Arr.length)

#4 
  
while(Arr.length > 0) {
    Arr.pop();
}





Sunday, October 25, 2020

Import MySQL Dump file using MySQL Command Line tool in windows 10

 

It really pain and may be you are facing same kind of issues which i faced so far to import mysql dump file using MySQL Command line tool in windows 10. 

You will be able to find multiple posts about SOURCE command you need to use but here certain things which might you also not able to find and still struggling with proper information. 


So easy solution here is : 


mysql> use db_name;

mysql> SET autocommit=0 ; source the_sql_file.sql ; COMMIT ;

But few catches here : 
First Catch : 

Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.

Example:

with backslashes : source C:\folder1\metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql



Second Catch : 

 filename must not be in quotes even if it contains spaces in name or path to file.



Wednesday, October 21, 2020

Remove all packages from a specific project within a solution

 Be careful: This will uninstall ALL packages in the project. If -Force parameter is used, packages are removed even if dependencies exist.

Get-Package -ProjectName "YourProjectName" | 
Uninstall-Package -ProjectName "YourProjectName" -RemoveDependencies -Force

Remove all packages from all projects in the solution

 Be careful: This will uninstall ALL packages in the solution. If -Force parameter is used, packages are removed even if dependencies exist.

Get-Package | Uninstall-Package -RemoveDependencies -Force

Thursday, January 2, 2020

How to check the value of observable in console.log ?

With a regular observable you only get the value when it changes, so if you want to console.log out the value you will need to console.log it in the subscription:



  this.buyer12Org$ = this.GetOrg();
  this.buyer12Org$.subscribe((res=> console.log('buyer12'res));

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...