开发者

how to write combined query to access data in asp.net mvc3

开发者 https://www.devze.com 2023-03-14 05:50 出处:网络
i am designing a project inasp.net mvc3, i have designed database in sql server, and i added this in App_Data using ADO.net connection.

i am designing a project in asp.net mvc3, i have designed database in sql server, and i added this in App_Data using ADO.net connection.

this is my ProductFormulation Tabl开发者_高级运维e

how to write combined query to access data in asp.net mvc3

and this is my RawMaterial table

how to write combined query to access data in asp.net mvc3

now i want to get Code from RawMaterial table where ProductID=1 in ProductFormulation. please tell me what query should i write. I am using Razor view engine.


select rm.Code 
from RawMaterial rm 
    inner join ProductFormulation pf 
        on pf.RawMaterialId = rm.id 
where pf.productid = 1

should get you where you need to go


Write in ur controller ->any function

var res = (from x in RawMaterial 
join y in ProductFormulation on x.ID equals y.ID where y.productID = 1 select y.Code)
return View(res);
0

精彩评论

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