私はプロパティのエージェントで構成されたクラスを持っています。各エージェントはそれらに対して複数のプロパティを持っていますので、私のビューモデルでは以下のことがあります。私はちょうどどのようにしてクラスに結合しますが、セカンドクラスを部分ビューに送信しますか?
public class Agents
{
public int AgentId { get; set; }
public int RatingsId { get; set; }
public string Name { get; set; }
public string About { get; set; }
public string Bookerish { get; set; }
public string Specialties { get; set; }
public int LicenseNo { get; set; }
public string image { get; set; }
public double LocalKnowledge { get; set; }
public double ProcessExpertise { get; set; }
public double Responsiveness { get; set; }
public double NegotiationSkills { get; set; }
public int Reviews { get; set; }
public double RatingAverage { get; set; }
public List<Property> Properties { get; set; }
}
プロパティクラス
public class Property
{
public int PropertyId { get; set; }
public string image { get; set; }
public string Details { get; set; }
public string reprsented { get; set; }
public decimal Price { get; set; }
public int Beds { get; set; }
public double Baths { get; set; }
public double SQFT { get; set; }
public Boolean isFeatuered { get; set; }
public int isActiveListing { get; set; }
public Boolean isPastSale { get; set; }
}
モデルエージェント、私はどのようにここにいる
@{
ViewData["Title"] = "About";
}
@Html.Partial("ActiveListings.cshtml")
<div class="l-divider l-divider--big"></div>
の下にリストされているAgent.cshtmlの私の見解でビューにエージェントを参照する場合私の質問はモデルに送信するプロパティにアクセスして、格納されているそのエージェントのプロパティのリストをレンダリングすることになります。
ここでエージェントのモデルプロパティをここに追加する必要があります。
@ Html.Partial(「ActiveListings.cshtml」)マイエージェントコントローラで
私はここに私のproperiesを追加する必要があり、次のindexメソッドを持っています。
Agents _newAgent = new Agents();
_newAgent.AgentId = 5;
_newAgent.Name = "Melissa Crosby";
_newAgent.Specialties = "Property Management, Buyer’s Agent, Listing Agent";
_newAgent.Bookerish = " Berkshire Hathaway HomeServices Elite Real Estate";
_newAgent.image = "uploads/agents/5.png";
_newAgent.Reviews = 16;
_newAgent.RatingAverage = 4.5;
_newAgent.LocalKnowledge = 4.5;
_newAgent.ProcessExpertise = 4.2;
_newAgent.NegotiationSkills = 4.1;
_newAgent.About = "<p> Being a full-service Realtor since 2007, I have been baptized by fire in a very tough housing market. I have successfully closed over 60 transactions and processed over 70 short sales both as the listing agent and some for other agents. I am very knowledgeable about lenders and their processes. I strive to exceed expectations and never forget that I am always accountable to my clients. </p> <p> My objective is to establish relationships for life, not just for the current transaction. I enjoy assisting home buyers and sellers to get moved to a better place, one that is exciting. </p>";
_newAgent.LicenseNo = 5452129;
return View(_newAgent);
}
オブジェクトここではbtwを表示する@model Agentsを持っている私はどのように私はプロパティを使用するビューを教えてくれるだろう – rogue39nin
更新された答えを参照してください。部分ビューはPropertyクラスのリストに強く型付けされます。 – Shyju
しかし、そのAgents.Propertyによってこれが引き続きエージェントに保存されたデータをプルしますか? – rogue39nin