/// <Summary>
/// Able for object Conversion
/// </Summary>
/// <Param name = "entity"> Object </param>
/// <Returns> datatable </returns>
Public static datatable getdatatablebyentity (Object entity)
{
Datatable dt = new datatable ();
Type type = entity. GetType ();
DT. tablename = type. Name;
Datarow DR = DT. newrow ();
Foreach (var p in type. getproperties ())
{
If (! DT. Columns. Contains (P. Name ))
DT. Columns. Add (P. Name );
Dr [P. Name] = P. getvalue (entity, null) = NULL? "": P. getvalue (entity, null). tostring ();
}
DT. Rows. Add (DR );
Return DT;
}
/// <Summary>
/// Convert list to able
/// </Summary>
/// <Typeparam name = "T"> Object Type </typeparam>
/// <Param name = "list"> list set </param>
/// <Returns> datatable </returns>
Public static datatable getdatatablebylist <t> (list <t> List)
{
Datatable dt = new datatable ();
Foreach (t in List)
{
Datarow DR = DT. newrow ();
Type type = T. GetType ();
If (string. isnullorempty (Dt. tablename ))
DT. tablename = type. Name;
Foreach (var p in type. getproperties ())
{
If (! DT. Columns. Contains (P. Name ))
DT. Columns. Add (P. Name );
Dr [P. Name] = P. getvalue (T, null) = NULL? "": P. getvalue (T, null). tostring ();
}
DT. Rows. Add (DR );
}
Return DT;
}
Object, list generic conversion to able