I want to display two joined tables from my SQL Server 2017 using C#. I followed this YouTube video. When everything seemed so perfectly fine, I get this error:
System.NullReferenceException 'Object reference not set to an instance of an object.'
I found out it was because of the null I set in my table.
I knew I could use the LEFT JOIN to handle the null values. But the problem is I don't know how to include the SQL command in my C# file.
The highlighted error line is : <td>@item.rule.Amount</td>
The suspected part I think I did wrong is
public ActionResult Index()
{ 
    db1 sd = new db1();
    List<Group> groups = sd.Groups.ToList();
    List<Rule> rule = sd.Rules.ToList();
    List<RuleDesc> ruleDesc = sd.RuleDescs.ToList();
    ViewData["jointtables"] = from g in groups
                              join r in rule on g.AcctNo equals r.AcctNo 
                              into table1
                              from r in table1.DefaultIfEmpty()
                              select new Class1 { groups = g, rule = r};
    return View(ViewData["joinedtables"]);
}
 
     
     
    