public DataObjects GetDataObjectCRMLead(int objectID, LeadRecord LeadRec) { ScriptObject Dob = GetDataObjectbyID(objectID); DataObjects DO = new DataObjects(); DO.DOID = Dob.ScriptObjectID; DO.DOName = Dob.ObjectName; List <DataObjects> theObs = new List <DataObjects>(); Int32 thecount = 0; Type objtype = LeadRec.GetType(); PropertyInfo[] FIS = objtype.GetProperties(); string stringval; Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (PropertyInfo fi in FIS) { switch (fi.PropertyType.Name) { case "String": stringval = (string)objtype.InvokeMember(fi.Name, BindingFlags.GetProperty, null, LeadRec, null); dictionary.Add(fi.Name, stringval); break; case "DateTime": DateTime datetimecol = (DateTime)objtype.InvokeMember(fi.Name, BindingFlags.GetProperty, null, LeadRec, null); stringval = datetimecol.ToString(); dictionary.Add(fi.Name, stringval); break; } } foreach (LeadRecordAttribute LRA in LeadRec.LeadRecordAttributes) { dictionary.Add(LRA.LeadAttributeName, LRA.LeadAttributeValue); } DO.Details = FillDetails(Dob.ScriptObjectID); DO.DictionaryMatch(dictionary); return(DO); }