public static List <Temp> GetMetaData(this PartCode entityObject) { XERP.Server.DAL.PartDAL.DALUtility dalUtility = new DALUtility(); List <Temp> tempList = new List <Temp>(); int id = 0; using (PartEntities ctx = new PartEntities(dalUtility.EntityConectionString)) { var c = ctx.PartCodes.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); }
public int Save(PartCode PartCode) { if (PartCode.PartCodeID == 0) { _context.PartCodes.Add(PartCode); } else { PartCode _dbEntry = _context.PartCodes.Find(PartCode.PartCodeID); if (_dbEntry != null) { _dbEntry.Name = PartCode.Name; _dbEntry.ShortName = PartCode.ShortName; _dbEntry.Code = PartCode.Code; } } _context.SaveChanges(); return(PartCode.PartCodeID); }
/// <summary> /// 从字典中获取合适的代码 /// </summary> /// <param name="type">UI类型</param> /// <param name="part">获取代码片段</param> /// <param name="selctGoName">选择的GameObject名称</param> /// <returns></returns> public static Dictionary <string, string> GetAppropriateCodeFromDic(UIComponentType type, PartCode part, string selctGoName, string selectGoPath) { Dictionary <string, string> codeDict = new Dictionary <string, string>(); string partCode; switch (part) { case PartCode.Define | PartCode.Path | PartCode.Component: { //Path predefineRules.TryGetValue(type + "" + PartCode.Path, out partCode); codeDict.Add(selctGoName + PartCode.Path, partCode.Replace("XXXXX", selctGoName).Replace("PPPPP", selectGoPath)); //Define predefineRules.TryGetValue(type + "" + PartCode.Define, out partCode); codeDict.Add(selctGoName + PartCode.Define, partCode.Replace("XXXXX", selctGoName)); //Component predefineRules.TryGetValue(type + "" + PartCode.Component, out partCode); codeDict.Add(selctGoName + PartCode.Component, partCode.Replace("XXXXX", selctGoName)); } break; case PartCode.Define | PartCode.Path | PartCode.Component | PartCode.Method: { predefineRules.TryGetValue(type + "" + PartCode.Define, out partCode); codeDict.Add(selctGoName + PartCode.Define, partCode.Replace("XXXXX", selctGoName)); predefineRules.TryGetValue(type + "" + PartCode.Component, out partCode); codeDict.Add(selctGoName + PartCode.Component, partCode.Replace("XXXXX", selctGoName)); predefineRules.TryGetValue(type + "" + PartCode.Method, out partCode); codeDict.Add(selctGoName + PartCode.Method, partCode.Replace("XXXXX", selctGoName)); } break; case PartCode.Path | PartCode.Define | PartCode.Component | PartCode.EventStatement | PartCode.RegisterEvent | PartCode.UnRegisterEvent: { //Path predefineRules.TryGetValue(type + "" + PartCode.Path, out partCode); codeDict.Add(selctGoName + PartCode.Path, partCode.Replace("XXXXX", selctGoName).Replace("PPPPP", selectGoPath)); //Define predefineRules.TryGetValue(type + "" + PartCode.Define, out partCode); codeDict.Add(selctGoName + PartCode.Define, partCode.Replace("XXXXX", selctGoName)); //Component predefineRules.TryGetValue(type + "" + PartCode.Component, out partCode); codeDict.Add(selctGoName + PartCode.Component, partCode.Replace("XXXXX", selctGoName)); //EventStatement predefineRules.TryGetValue(type + "" + PartCode.EventStatement, out partCode); codeDict.Add(selctGoName + PartCode.EventStatement, partCode.Replace("XXXXX", selctGoName)); //RegisterEvent predefineRules.TryGetValue(type + "" + PartCode.RegisterEvent, out partCode); codeDict.Add(selctGoName + PartCode.RegisterEvent, partCode.Replace("XXXXX", selctGoName)); //UnRegisterEvent predefineRules.TryGetValue(type + "" + PartCode.UnRegisterEvent, out partCode); codeDict.Add(selctGoName + PartCode.UnRegisterEvent, partCode.Replace("XXXXX", selctGoName)); } break; } return(codeDict); }