سلام.من چطور می توانم این کوری را در مدل بنویسم وقتی که به شی کانتکس ایراد می گیرد که وجود ندارد.به db ایراد می گیرد.
لطفا راهنمایی کنید.
var bimeshode = ( from c in db.tblbimeshodeParents join p in db.tblbimeshodeChildes on c.fldID equals p.fldParetId into ps select new { Category = c, Products = ps }).ToList();
همچنین وقتی که از دو تیبل یک ویو مدل کلی می سازیم تکلیف فیلد های هم نام چیست.چطور می شود در مدل alias تعریف کرد؟
کلید های اصلی دو تیبل هم ایا در ویو مدل تعریف می شوند؟
ممنونم از راهنمایی های شما
در View نوشتید ؟
باید در بالای View یک نمونه از Context بسازید
بله در view،اما به
EsContext ایراد می گیرد که نمی شناسد
@model IEnumerable<esdarman01.Models.Reportbimeshode> @{ Layout = null; } @{ private EsContext db = new EsContext(); var bimeshode = ( from c in db.tblbimeshodeParents join p in db.tblbimeshodeChildes on c.fldID equals p.fldParetId into ps select new { Category = c, Products = ps }).ToList(); } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>Reportbimeshode</title> </head> <body> </body> </html>
متن خطا را قرار دهید
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'EsContext' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 1: @model IEnumerable<esdarman01.Models.Reportbimeshode>
Line 2: @{ EsContext db = new EsContext(); }
Line 3: @{
Line 4: Layout = null;
Source File: D:\Myprojectsample\MVC project\New folder (2)\esdarman01\Areas\Admin\Views\Report\Reportbimeshode.cshtml Line: 2
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0
فضای نام را باید اضافه کنید
مثلا
@using MyProject.Model
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)