/// <summary> /// 判断是否存在引用 /// </summary> /// <param name="db">数据库上下文</param> /// <param name="field">字典表对象</param> /// <returns>是否存在引用(true:是,false:否)</returns> public bool ExistsReference(SysEntities db, SysField field) { bool bResult = false; if (db != null && field != null) { String sql = String.Format("select Value o from SysEntities.{0} as o where o.{1}=@id", field.MyTables, field.MyColums); var reader = db.CreateQuery <DbDataReader>(sql, new ObjectParameter("id", field.Id)); bResult = reader.Count() > 0; } return(bResult); }