asp.net MVC4(かみそり構文)とデータベースファーストのアプローチを使用して、1ページのアプリケーションを構築しようとしています。以下のように、私のアプリケーションの簡単なモックアップを見ることができます。
-OPPORTUNITY<br />
--OPPORTUNITY DETAIL(1)<br />
---Seleted Solution-1<br />
---Seleted Solution-2<br />
---Seleted Solution-3<br />
--OPPORTUNITY DETAIL(2)<br />
---Seleted Solution-1<br />
---Seleted Solution-2<br />
--OPPORTUNITY DETAIL(3)<br />
---Seleted Solution-1<br />
---Seleted Solution-2<br />
---Seleted Solution-3<br />
テーブルには多くのソリューションがあり、多くのパラメーターがあります。すべての情報を 1 ページに表示する最善の方法は何ですか。新しいビューモデルを作成しようとしています。ただし、テーブルからすべてのデータを取得しているため、パフォーマンスについてはわかりません。
これが私のモデルクラスです..
機会クラス
namespace CRM_V1.Models
{
using System;
using System.Collections.Generic;
public partial class CRM_OPPORTUNITIES
{
public CRM_OPPORTUNITIES()
{
this.CRM_OP_ATTACHMENTS = new HashSet<CRM_OP_ATTACHMENTS>();
this.CRM_OPP_DETAILS = new HashSet<CRM_OPP_DETAILS>();
}
public decimal ID { get; set; }
public Nullable<decimal> COMPANYID { get; set; }
public Nullable<decimal> SEGMENTID { get; set; }
public Nullable<decimal> SEGMENTDETAILID { get; set; }
public Nullable<decimal> CUSTOMERID { get; set; }
public Nullable<decimal> PROJECTID { get; set; }
public Nullable<decimal> STATUSID { get; set; }
public Nullable<System.DateTime> CRDATE { get; set; }
public Nullable<decimal> CRUSER { get; set; }
public string CODE { get; set; }
public Nullable<System.DateTime> MDDATE { get; set; }
public Nullable<decimal> MDUSER { get; set; }
public Nullable<decimal> IS_VALID { get; set; }
public Nullable<decimal> OWNERID { get; set; }
public Nullable<decimal> PRJCTGRPID { get; set; }
public Nullable<decimal> ORDERSUMMARY { get; set; }
public string NOTES { get; set; }
public virtual CRM_COMPANIES CRM_COMPANIES { get; set; }
public virtual CRM_CUSTOMERS CRM_CUSTOMERS { get; set; }
public virtual ICollection<CRM_OP_ATTACHMENTS> CRM_OP_ATTACHMENTS { get; set; }
public virtual CRM_OP_STATUS CRM_OP_STATUS { get; set; }
public virtual ICollection<CRM_OPP_DETAILS> CRM_OPP_DETAILS { get; set; }
public virtual CRM_SEGMENTS CRM_SEGMENTS { get; set; }
public virtual CRM_SEGMENT_DETAILS CRM_SEGMENT_DETAILS { get; set; }
public virtual CRM_PROJECTS CRM_PROJECTS { get; set; }
public virtual CRM_PRJCT_GROUPS CRM_PRJCT_GROUPS { get; set; }
}
}
詳細クラス
namespace CRM_V1.Models
{
using System;
using System.Collections.Generic;
public partial class CRM_OPP_DETAILS
{
public CRM_OPP_DETAILS()
{
this.CRM_OPP_DETAILS1 = new HashSet<CRM_OPP_DETAILS>();
this.CRM_REVENUE_PLAN = new HashSet<CRM_REVENUE_PLAN>();
this.CRM_SOLUTION_DISTRIBUTION = new HashSet<CRM_SOLUTION_DISTRIBUTION>();
}
public decimal ID { get; set; }
public string CODE { get; set; }
public Nullable<decimal> OPPID { get; set; }
public Nullable<decimal> ORDERAMOUNT { get; set; }
public Nullable<System.DateTime> ORDERDATE { get; set; }
public string ORDERCURRENCY { get; set; }
public Nullable<decimal> REVENUEAMOUNT { get; set; }
public Nullable<System.DateTime> REVENUEDATE { get; set; }
public Nullable<decimal> REVENUECURRENCY { get; set; }
public Nullable<short> MARGINRATE { get; set; }
public Nullable<System.DateTime> TARGETDATE { get; set; }
public Nullable<short> POSSIBILITY { get; set; }
public Nullable<decimal> STATUSID { get; set; }
public string NOTES { get; set; }
public Nullable<System.DateTime> CRDATE { get; set; }
public Nullable<decimal> CRUSER { get; set; }
public Nullable<System.DateTime> MDDATE { get; set; }
public Nullable<decimal> MDUSER { get; set; }
public Nullable<decimal> IS_VALID { get; set; }
public Nullable<decimal> TYPEID { get; set; }
public Nullable<decimal> OWNERID { get; set; }
public Nullable<decimal> AFFLDETAILID { get; set; }
public Nullable<decimal> REVENUEDOLLAR { get; set; }
public Nullable<decimal> ORDERDOLLAR { get; set; }
public Nullable<decimal> ISHAVEREVPLAN { get; set; }
public Nullable<decimal> SOLPLANDONE { get; set; }
public Nullable<decimal> SOLUTIONID { get; set; }
public string PAFDCANO { get; set; }
public Nullable<decimal> DCAKOD { get; set; }
public virtual CRM_OP_DETAIL_STATUS CRM_OP_DETAIL_STATUS { get; set; }
public virtual CRM_OPP_DETAIL_TYPE CRM_OPP_DETAIL_TYPE { get; set; }
public virtual CRM_OPPORTUNITIES CRM_OPPORTUNITIES { get; set; }
public virtual ICollection<CRM_OPP_DETAILS> CRM_OPP_DETAILS1 { get; set; }
public virtual CRM_OPP_DETAILS CRM_OPP_DETAILS2 { get; set; }
public virtual ICollection<CRM_REVENUE_PLAN> CRM_REVENUE_PLAN { get; set; }
public virtual ICollection<CRM_SOLUTION_DISTRIBUTION> CRM_SOLUTION_DISTRIBUTION { get; set; }
}
}
ソリューション配布クラス
namespace CRM_V1.Models
{
using System;
using System.Collections.Generic;
public partial class CRM_SOLUTION_DISTRIBUTION
{
public CRM_SOLUTION_DISTRIBUTION()
{
this.CRM_SOLUTION_VENDOR = new HashSet<CRM_SOLUTION_VENDOR>();
}
public decimal ID { get; set; }
public Nullable<decimal> OPPDETAILID { get; set; }
public Nullable<decimal> SOLUTIONID { get; set; }
public Nullable<decimal> CRUSER { get; set; }
public Nullable<System.DateTime> CRDATE { get; set; }
public Nullable<decimal> MDUSER { get; set; }
public Nullable<System.DateTime> MDDATE { get; set; }
public Nullable<decimal> AMOUNT { get; set; }
public Nullable<decimal> IS_VALID { get; set; }
public string CURRENCY { get; set; }
public Nullable<decimal> AMOUNTDOLLAR { get; set; }
public Nullable<decimal> MARGIN { get; set; }
public Nullable<decimal> MARGINRATE { get; set; }
public Nullable<decimal> DISTMARGIN { get; set; }
public Nullable<decimal> VENDORID { get; set; }
public Nullable<System.DateTime> VENDORDATE { get; set; }
public virtual CRM_OPP_DETAILS CRM_OPP_DETAILS { get; set; }
public virtual CRM_SOLUTIONS CRM_SOLUTIONS { get; set; }
public virtual CRM_VENDORS CRM_VENDORS { get; set; }
public virtual ICollection<CRM_SOLUTION_VENDOR> CRM_SOLUTION_VENDOR { get;
最初に機会と関連する詳細を表示するモデルビューを作成することから始めましたが、失敗しましたか?
これが私のモデルビュークラスです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CRM_V1.Models;
namespace CRM_V1.ViewModels
{
public class OppViewModel
{
public List<CRM_OPPORTUNITIES> OppList { get; set; }
public List<CRM_OPP_DETAILS> OppDetailList { get; set; }
}
}
私のコントローラーアクション
public ActionResult addingDetailNew(decimal id = 0)
{
CRM_OPPORTUNITIES crm_opportunities = db.CRM_OPPORTUNITIES.Find(id);
var viewModel2 = new OppViewModel
{
viewModel2 = db.CRM_OPPORTUNITIES.ToList()
};
if (crm_opportunities == null)
{
return HttpNotFound();
}
return View(viewModel2);
}
そして最後に私の見解。
@model CRM_V1.ViewModels.OppViewModel
@{
ViewBag.Title = "addingDetailNew";
}
<h2>addingDetailNew</h2>
@Html.DisplayFor(model => model.NOTES)
しかし、NOTES フィールドを取得できませんでした。2 番目の質問は、 model.CUSTOMERS.NAME のような結合フィールドを取得する方法です。?
よろしく