daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT G.* FROM GOAL G
  2. INNER JOIN Plan P ON
  3. P.planID = G.planID
  4. INNER JOIN User U ON
  5. U.userID = P.userID
  6. WHERE U.userID = @userID
  7.    
  8. var plan = db.Plan.Where(b => b.UserID == CurrentUserID).FirstOrDefault();
  9. Goal goal = db.Goals
  10.             .Where(b => b.PlanID == plan.ID)
  11.             .FirstOrDefault();
  12. return View(goal);
  13.    
  14. public class Plan
  15. {
  16.     public int ID { get; set; }
  17.     [Required]
  18.     public int UserID { get; set; }
  19. }
  20. [Table("PlanGoal")]
  21. public class Goal
  22. {
  23.     public int ID { get; set; }
  24.  
  25.     [Required]
  26.     public int PlanID { get; set; }
  27. }
  28.    
  29. Goal goal = (from g in db.Goals
  30.             from p in db.Plan
  31.             where p.UserID == CurrentUserID
  32.              && g.PlanID == p.ID
  33.             select g).FirstOrDefault();
  34.    
  35. public class Goal
  36. {
  37.     public int ID { get; set; }        
  38.     public virtual Plan Plan { set;get;}    
  39.     [Required]
  40.     public int PlanID { get; set; }
  41. }
  42.    
  43. Goal goal = db.Goals
  44.             .Where(b => b.Plan.UserID == CurrentUserID).FirstOrDefault();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top