This project is read-only.
Simple SQL Server provider (both SQL SERVER 2005/8/2012 and SQL Compact 4.0).
It abstracts the sql provider layer in order to switch elegantly between the server repository and the local one.


You should call the static load method in order to configure the connection to the repository.


Also it requires some configuration in the app.config or the web.config. First of all the declaration of all the <DbProviderFactories> you want to connect with.

<add key="dataprovider" value="System.Data.SqlClient"/>
<!--<add key="dataprovider" value="System.Data.SqlServerCe.4.0"/>-->

This is an example:

public static List<T> ritornaTop(byte top, bool stato)
List<T> cop = new List<T>();

var sql = "SELECT top(@top) id, titolo, descrizione, img, stato FROM TABLE WHERE stato=@stato order by id DESC ";

var d = new Dictionary<string, dynamic>();
d.Add("stato", stato);
d.Add("top", top);

DataTable table = DataFactory.executeDataTable(sql, d);

for (int i = 0; i < table.Rows.Count; i++)
var row = table.Rows[i];
var cope = new T(); = Convert.ToInt32(row["id"]);
cope.titolo= row["titolo"].ToString();
cope.descrizione = row["descrizione"].ToString();
cope.img = row["img"].ToString();
cope.stato = Convert.ToBoolean(row["stato"]);
return cop;

Last edited May 26, 2013 at 7:59 AM by mauro_ghiani, version 2