SQL Notes

1. SQL Examples

1.1. Stored Procedures

1.1.1. Dynamic Where Clause

WHERE 1 = 1
AND (@what     IS NULL OR [companies_SimpleList].[Description] Like @What )
AND (@keywords IS NULL OR companies_SimpleList.Keywords        Like @Keywords)
AND (@where    IS NULL OR companies_SimpleList.FullAdress      Like @Where)

The WHERE 1 = 1 phrase is strictly for alignment purposes and is not actually required.

2. Entity Framework Examples

2.1. Group By Clause

Doc can be found here.

2.2. In Clause

Doc can be found here.

var idArray = new int[]{1,2,3,45,99};
using (DatabaseEntities db = new DatabaseEntities ())
{
    return db.Licenses.Where(
        i => i.license == mylicense
         && idArray.Contains(i.number)
        ).ToList();
}