开发者

Type or namespace could not be found

开发者 https://www.devze.com 2022-12-22 12:59 出处:网络
I\'m using LINQ to SQL to connect my database to my home page. I created my datacontext (named businessModel.dbml) In it I have two tables named Category and Business.

I'm using LINQ to SQL to connect my database to my home page. I created my datacontext (named businessModel.dbml) In it I have two tables named Category and Business.

In home controller I reference the model and attempt to return to the view the table:

var dataContext = new businessModelDataContext();
var business = from b in dataContext.Businesses
select b;
ViewData["WelcomeMessage"] = "Welcome to Jerome, Arizona!";
ViewData["MottoMessage"] = "Largest Ghost Town in America!";

return View(business);

and in the view I have th开发者_开发百科is:

<%@ Import Namespace="WelcomeToJerome.Models" %>

and

<% foreach (business b in (IEnumerable)ViewData.Model)
           { %>
        <li><%= b.Title %></li>
        <% } %>

Yet, in the view business is cursed with the red underline and say's that The type or namespace name 'business' could not be found (are you missing a using directive or an assembly reference?)

What am I doing wrong? This has had me stumped all afternoon.

link to all the code in pastebin: http://pastebin.com/es4RnS2q


Try capitalizing the B, judging by your table name, it should be Business instead of business.


Well, WelcomeToJerome.Models is a namespace from some assembly, which must be referenced in your Web.config in order for the ASP.NET compiler to find it. You don't show the Web.config, but I'm betting the assembly isn't properly referenced there.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号