//All senior tables(Companies, Parts, Orders, ect...) tend to have a generic table called TableNameTypes //i.e. CompanyTypes PartTypes, OrderTypes... //So this will constitute the meta data for that Type table... //Xerp attempts to use generic naming where possible to allow for cloning... public static List <Temp> GetMetaData(this CompanyType entityObject) { XERP.Server.DAL.CompanyDAL.DALUtility dalUtility = new DALUtility(); List <Temp> tempList = new List <Temp>(); int id = 0; using (CompanyEntities ctx = new CompanyEntities(dalUtility.EntityConectionString)) { var c = ctx.CompanyTypes.FirstOrDefault(); var queryResults = from meta in ctx.MetadataWorkspace.GetItems(DataSpace.CSpace) .Where(m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType) from query in (meta as EntityType).Properties .Where(p => p.DeclaringType.Name == entityObject.GetType().Name) select query; if (queryResults.Count() > 0) { foreach (var queryResult in queryResults.ToList()) { Temp temp = new Temp(); temp.ID = id; temp.Name = queryResult.Name.ToString(); temp.ShortChar_1 = queryResult.TypeUsage.EdmType.Name; if (queryResult.TypeUsage.EdmType.Name == "String") { temp.Int_1 = Convert.ToInt32(queryResult.TypeUsage.Facets["MaxLength"].Value); } temp.Bool_1 = false; //we use this as a error trigger false = not an error... tempList.Add(temp); id++; } } } return(tempList); }
private void UpdateObject(CompanyType _newCompanyType, ref CompanyType _oldCompanyType) { try { foreach (PropertyInfo CompanyTypePropInfo in _newCompanyType.GetType().GetProperties().ToList()) { _oldCompanyType.GetType().GetProperty(CompanyTypePropInfo.Name).SetValue(_oldCompanyType, _newCompanyType.GetType().GetProperty(CompanyTypePropInfo.Name).GetValue(_newCompanyType)); } } catch (Exception e) { Console.WriteLine(e); throw; } }
private void FillPropNames(CompanyType T) { if (T != null) { PropertyInfo[] properties1 = T.GetType().GetProperties(); foreach (var p in properties1) { string s = p.PropertyType.ToString(); if (!p.PropertyType.IsClass || p.PropertyType.ToString().Contains("String")) { if (!p.PropertyType.ToString().Contains("ICollection")) { HeaderList.Add(p.Name); } } } } }