Stored Procedure e EF

Entity Framework supporta le Stored Procedure attraverso le “Function Imports”, le quali creano dei metodi all’interno della classe “DbContext” per mezzo dei quali è possibile chiamare le varie Stored Procedure.
using (NorthwindEntities northWindContext = new NorthwindEntities())
{
List employeesList = northWindContext.spGetEmployees().ToList();
}
public virtual ObjectResult spGetEmployees()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("spGetEmployees");
}

Nel codice mostrato sopra c’è un esempio di una chiamata ad un metodo creato importando la Stored Procedure, e l’implementazione del metodo stesso.

Continue reading Stored Procedure e EF

Show on All Tabs

When it’s developping a windows form application the “TabControl” is one of controls more used by me.

If you need to show same control that has same data es. a panel in the all or several tabs, you can change the parent of control at runtime, specifyng the tab selected.

The event to manage it is “Selected” from TabControl, see the following code:


private void tcColor_Selected(object sender, TabControlEventArgs e)
{
pnlRed.Parent = e.TabPage;
pnlOrange.Parent = e.TabPage;
pnlYellow.Parent = e.TabPage;
pnlGreen.Parent = e.TabPage;
pnlAcqua.Parent = e.TabPage;
pnlBlue.Parent = e.TabPage;
}

Search Full DataBase

The searches in the database are very common, but sometimes it doesn’t know the table’s name or column’s name, but only the value to search.

I wrote a SQL Script that executes the search in the database, then in all columns.

The SQL Script can work on tables of sys namespace or on INFORMATION_SCHEMA namespace, in this situation they’re equivalent.

Continue reading Search Full DataBase