私は2つのテーブルを「ユーザー」と「サブスクリプション」と呼んでいます。これらのコントローラを使用してすべてのユーザーデータを取得できますが、Subscriptionステータスが1のサブスクリプション列の「ステータス」のユーザーデータのみを取得します。私の結果をフィルタリングするにはどうすればよいですかリレーションによるデータフィルタ
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using WebApplication2.Models;
namespace WebApplication2.Controllers
{
public class EmailCampaignController : Controller
{
private db_likEntities db = new db_likEntities();
// GET: Only Subscribed Users info
public ActionResult Index()
{
var users = db.Users.Include(u => u.Countries);
return View(users.ToList());
}
}
}
どのようにユーザーとサブスクリプションテーブルが関連していますか? –
ユーザーの外部キーをサブスクリプション列= "UserId"に保存して、その関係を確認しました –
ユーザークラスにサブスクリプションプロパティがありますか?ユーザーansサブスクリプションクラスを共有できますか? –