首页 > 应用开发 > IT综合 > 何时该用泛型类何时该用泛型方法
class Gclass
{
}
class Class
{
public Gm ()
{
}
}
class SQLHelper
{
private string _ConnectString = "Data Source=xxxx;Initial Catalog=EmrcDBStationW;Persist Security Info=True;User ID=sa;pwd=future;";
public string ConnectString
{
get { return _ConnectString; }
set { _ConnectString = value; }
}
///
/// Inserts the specified o.
///
/// The o.
///
public int Insert(T Entity)
{
int ret = 1;
Grove.ORM.ObjectOperator oo = new ObjectOperator(ConnectString);
oo.BeginTranscation();
try
{
oo.Insert(Entity);
oo.Commit();
}
catch (Exception ex)
{
oo.Rollback();
ret = 0;
}
return ret;
}
///
/// Updates the specified entity.
///
/// The entity.
///
public int Update(T Entity)
{
int ret = 1;
Grove.ORM.ObjectOperator oo = new ObjectOperator(ConnectString);
oo.BeginTranscation();
try
{
oo.Update(Entity);
oo.Commit();
}
catch (Exception ex)
{
oo.Rollback();
ret = 0;
}
return ret;
}
public int Update(string filter, params string[] UpdateItem)
{
int ret = 1;
Grove.ORM.ObjectOperator oo = new ObjectOperator(ConnectString);
oo.BeginTranscation();
try
{
oo.Update(typeof(T), filter, UpdateItem);
oo.Commit();
}
catch (Exception ex)
{
oo.Rollback();
ret = 0;
}
return ret;
}
///
/// Deletes the specified entity.
///
/// The entity.
///
public int Delete(T Entity)
{
int ret = 1;
Grove.ORM.ObjectOperator oo = new ObjectOperator(ConnectString);
oo.BeginTranscation();
try
{
oo.Remove(Entity);
oo.Commit();
}
catch (Exception ex)
{
oo.Rollback();
ret = 0;
}
return ret;
}
///
/// Deletes the specified filter.
///
/// The filter.
///
public int Delete(string filter)
{
int ret = 1;
Grove.ORM.ObjectOperator oo = new ObjectOperator(ConnectString);
oo.BeginTranscation();
try
{
oo.Remove(typeof(T), filter);
oo.Commit();
}
catch (Exception ex)
{
oo.Rollback();
ret = 0;
}
return ret;
}
public DataTable GetData( string filter, string orderby)
{
int ret = 1;
Grove.ORM.ObjectOperator oo = new ObjectOperator(ConnectString);
ObjectQuery query=new ObjectQuery(typeof(T),filter,orderby);
DataSet Ds = oo.GetObjectSource(query);
return Ds.Tables[0];
}
}
public class LeanConfigSetingToXML: ILeanConfigSeting
{
public int SyncConfig ( string LeanNumber,string Filter,string orderby)
{
int ret = 1;
try
{
IEntity Table = DataAccess.CreateInstance ();
DataTable Dt;
Dt = Table.GetData(Filter, orderby);
string FilePath = @"ClinetConfigFile" + LeanNumber + Dt.TableName + ".xml";
Dt.WriteXml(FilePath);
}
catch
{
ret = 0;
}
return ret;
}
public int SyncCarType(string LeanNumber)
{
string filter = "laneNumber = '" + LeanNumber + "' and len(laneNumber)>0 and len(carType)>0 and len(standardCartypeExplain)>0 and len(laneNumber) >0";
return SyncConfig (LeanNumber, filter, "");
}
}来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7317239/viewspace-915518/ ,如需转载,请注明出处,否则将追究法律责任。