static void Main(string[] args) { CParameter <int> ints = new CParameter <int>(); CParameter <long> longs = new CParameter <long>(); CInformation info = new CInformation(); info.AddParameter(ints); info.AddParameter(longs); CParameter <int> ints2 = info.GetParameter <int>(); }
static void Main(string[] args) { CParameter <int> ints = new CParameter <int>(); CParameter <long> longs = new CParameter <long>(); CInformation info = new CInformation(); info.AddParameter(ints); info.AddParameter(longs); CParameter <int> ints2 = info.GetParameter <int>(); // ints2 and ints will both refer to the same CParameter instance. }
// GET: Information public ActionResult ListPaging(int pageNum = 1, string p_priority = "ALL", string p_read_yn = "N", string p_query_type = "999", string p_data = "N") { try { //int memberID = 1; CMember member = Session[CDictionary.welcome] as CMember; //modify by Jony 109-12-15 int memberID = 0; if (member != null) { memberID = member.fMemberId; } int pageSize = 5; int currentPage = pageNum < 1 ? 1 : pageNum; ViewBag.Read_YN = p_read_yn; //將partialview資料傳給 主要view ViewBag.Priority = p_priority; ViewBag.Query_Type = p_query_type; ViewBag.Query_Data = p_data; Func <Information, bool> myWhere = null; SingleApartmentEntities db = new SingleApartmentEntities(); IEnumerable <Information> table = null; //myWhere = p => p.Status != "User_Deleted"; //todo:ok Linq多重where //if (string.IsNullOrEmpty(read_yn)) //p_priority == "ALL" 顯示全部資料 if (p_query_type == "999" && p_priority == "ALL") { myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted"; } else if (p_query_type == "999" && p_priority == "Null") { //p_priority == "Null" 顯示已讀或未讀資料 //移除 p.Priority == p_priority myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.Read_YN == p_read_yn; } else if (p_query_type == "999" && p_read_yn == "Null") { //p_read_yn == "Null" 顯示優先等級資料 //移除 p.Read_YN == p_read_yn myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.Priority == p_priority; } //<option value="999">請選擇查詢項目</option> // <option value="100">系統分類</option> // <option value="200">個人分類</option> // <option value="300">關鍵字</option> else if (p_query_type == "100") {//100 = 系統分類 myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.InformationCategoryID == Convert.ToInt32(p_data); } else if (p_query_type == "200") {//200 = 個人分類 if (p_data == "999") { myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.MemberCategoryID == null; } else { myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.MemberCategoryID == Convert.ToInt32(p_data); } } else if (p_query_type == "300") {//300 = 關鍵字 myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.InformationContent.Contains(p_data); } else if (p_query_type == "400") {//400 = 依訊息內容分類 myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.InformationSource == Convert.ToInt32(p_data); } else if (p_query_type == "500") {//500 = 依當日新訊息 if (p_data == "N") { myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.InformationDate.ToString("yyyy-MM-dd") == DateTime.Today.ToString("yyyy-MM-dd"); } else { myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.InformationDate.ToString("yyyy-MM-dd") == DateTime.Today.ToString("yyyy-MM-dd") && p.InformationSource == Convert.ToInt32(p_data); } } else { //no use //myWhere = p => p.MemberID == memberID && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" && p.Read_YN == p_read_yn && p.Priority == p_priority; } //modify by Jony 1091208 增加 .OrderBy(a=>a.InformationID) //modify by Jony 1091218 增加 .OrderByDescending(a=>a.InformationID) table = db.Information.Where(myWhere).OrderByDescending(a => a.InformationID); // myWhere = p => p.InformationContent.Contains(keyword) && p.Status != "User_Deleted" && p.Status != "Admin_Deleted"; // table = db.Information.Where(myWhere); // //table = from p in db.Information // // where p.InformationContent.Contains(keyword) && p.Status != "User_Deleted" && p.Status != "Admin_Deleted" // // select p; //} List <CInformation> list = new List <CInformation>(); foreach (Information item in table) { //list.Add(new CInformation() //{ // information_entity = item, // InformationCategoryName = item.InformationCategory.InformationCategoryName, // //三元運算子 // UserCategoryName = item.MemberCategoryID == null ? "未分類" : item.MemberInformationCategory.MemberCategoryName, //}); CInformation x = new CInformation(); x.information_entity = item; x.InformationCategoryName = item.InformationCategory.InformationCategoryName; x.UserCategoryName = item.MemberCategoryID == null ? "未分類" : item.MemberInformationCategory.MemberCategoryName; x.InformationSourceName = ""; if (x.InformationSource != null) { InformationContent c = db.InformationContent.Where(p => p.ContentID == item.InformationSource).FirstOrDefault(); //沒設關聯, 為了取得 UserCategoryName = MemberInformationCategory.MemberCategoryName if (c != null) { x.InformationSourceName = c.ContentName; //取得 訊息來源名稱 } } list.Add(x); } //return View(list); var pagedlist = list.ToPagedList(currentPage, pageSize); //return View(pagedlist); //Page_原始ok 此cshtml使用 return(PartialView(pagedlist));//使用部分顯示 } catch { return(View()); } }