, property.Name, entityType)) ;
} property;
}
} new ApplicationException (string.Format («No primary key defined for type {0}», entityType.Name));
} (Exception ex)
{
_appcontext.SysMsg.ReportMsg (ex.Message, avto.SysMsg.Interfaces.MsgType.Error);
}
_appcontext.SysMsg.ReportMsg (string.Format («No primary key defined for type {0}», entityType.Name), avto.SysMsg.Interfaces.MsgType.Error); null;
} T GetById (int _Id) where T: class
{
{itemParameter=Expression.Parameter (typeof (T), «item»); whereExpression=Expression.Lambda >
(. Equal (. Property (, (typeof (T)). Name
),. Constant (_Id)
), [] {itemParameter}
); rez=_datacontext.GetTable (). Where (whereExpression); (rez.Count ()> 0) rez.First ();
} (Exception ex)
{
_appcontext.SysMsg.ReportMsg (ex.Message, avto.SysMsg.Interfaces.MsgType.Error);
} null;
} bool Del (T obj) where T: class
{
{
_datacontext.GetTable<T>().DeleteOnSubmit(GetById<T>(GetID(obj)));();
} (Exception ex)
{false;
} true;
} bool DelByid (int id) where T: class
{
{
_datacontext.GetTable (). DeleteOnSubmit (GetById (id)); ();
} (Exception ex)
{false;
} true;
} bool Save (T obj) where T: class
{
{ID=GetID (obj); (ID> 0)
{oldobj=GetById (ID); (oldobj!=null)
{(PropertyInfo propertyitem in obj.GetType (). GetProperties ())
{oldproperty=oldobj.GetType (). GetProperty (propertyitem.Name);. SetValue (oldobj, propertyitem.GetValue (obj, null), null);
}
}
{
_appcontext.SysMsg.ReportMsg («Помилка пріпопитке додати дані» + obj.GetType (). ToString (), avto.SysMsg.Interfaces.MsgType.Error); false;
}
}
{
_datacontext.GetTable (). InsertOnSubmit (obj);
} ();
} (Exception ex)
{
_appcontext.SysMsg.ReportMsg (ex.Message, avto.SysMsg.Interfaces.MsgType.Error); false;
} true;
} IQueryable GetByFilter (Expression > filter) where T: class
{
{_datacontext.GetTable (). Where (filter);
} (Exception ex)
{
_appcontext.SysMsg.ReportMsg (ex.Message, avto.SysMsg.Interfaces.MsgType.Error);