void InitEntity() { EntityName = typeof(T).FullName; if (DictTable.ContainsKey(EntityName)) { TableAttribute ta = DictTable[EntityName]; InitTableAttribute(ta); return; } System.Reflection.MemberInfo info = typeof(T); //获取表结构定义 object[] aryCA = info.GetCustomAttributes(false); foreach (object ca in aryCA) { if (ca is ORM.TableAttribute) { TableAttribute ta = ca as ORM.TableAttribute; InitTableAttribute(ta); DictTable.Add(EntityName, ta); } } //获取属性 PropertyInfo[] aryPI = typeof(T).GetProperties(); foreach (PropertyInfo pi in aryPI) { object[] aryFA = pi.GetCustomAttributes(Type.GetType("CJia.ORM.FieldAttribute"), false); if (aryFA.Length == 0) { continue; } if (aryFA[0] is ORM.FieldAttribute) { ORM.FieldAttribute field = aryFA[0] as ORM.FieldAttribute; if (!DictField.ContainsKey(EntityName)) { DictField.Add(EntityName, new Dictionary <string, FieldAttribute>()); } if (field.isPrimaryKey) { PrimaryKey = field.Name; } DictField[EntityName].Add(pi.Name, field); } } }
public List <EmployeeInfo> GetEmployeeInfos(Guid[] ids, DictTable queryParam = null) { using (var db = new HRDbContext()) { var tenantId = this.GetCurrentCredential().TenantGuid(); var query = from c in db.HR_EMP_Employee.Where(c => c.TenantID == tenantId && !c.IsDeleted) join l in db.HR_ORG_LegalEntity.Where(p => !p.IsDeleted) on c.LegalEntityID equals l.LegalEntityID join area in db.HR_EMP_OfficeArea on c.OfficeAreaID equals area.AreaID into atemp from area in atemp.DefaultIfEmpty() where ids.Contains(c.EmployeeID) select new EmployeeInfo() { EmployeeId = c.EmployeeID, EmployeeName = c.EmployeeNameCN, EmployeeNo = c.EmployeeNumber, ExtCode = c.ExtCode, TeleCode = c.TeleCode, OfficeAreaID = c.OfficeAreaID, OfficeAreaName = area.AreaName, EMail = c.EmployeeEMail, Mobile = c.PersonalCellPhone, LegalID = c.LegalEntityID, LegalEntityName = l.LegalEntityName, MainJobPositionID = c.MainJobPositionID, MainJobPostionName = c.MainJobPostionName, OrganizationID = c.OrganizationID, OrganizationCode = c.OrganizationCode, OrganizationName = c.OrganizationName, OnboardDate = c.OnboardDate, TrialBeginDate = c.TrialBeginDate, TrialEndDate = c.TrialEndDate, PersonalCellPhone = c.PersonalCellPhone, }; return(query.ToList()); } }