c# - LINQ to SQL multiple tables left join -


i have stored procedure dynamic query s working fine in case when not creating return type edmx. trying use linq same stored procedure getting bit difficult newbie. can me on this.

here code

sql:

create procedure [dbo].[usp_getproductlist_searchformanytoone]  @orgid bigint,     @ownerid bigint,  @orderlist nvarchar(max)  begin     -- -- set nocount on added prevent result sets   -- -- interfering select statements.\   set nocount on;  declare @sql nvarchar(max) = ''         set @sql = 'select productid = ii.productid,    invitemid = convert(bigint,0),    name = p.name,    primaryimageid = p.primaryimageid,productnumberlabel = p.productnumberlabel,productnumber = p.productnumber,    category = isnull(c.name,''''),    qty = isnull((sum(ii.[quantityonhand]) - sum(ii.[quantitysold])), 0.00),    saleprice= isnull(p.saleprice, 0.00),    enteredquantity=(case when (isnull((sum(ii.[quantityonhand]) - sum(ii.[quantitysold])), 0.00) > 1) 1.00 else isnull((sum(ii.[quantityonhand]) - sum(ii.[quantitysold])), 0.00) end)    ,discount=0,u.unitname,    u.unitid         dbo.[inventoryitems] ii      left join dbo.[product] p on ii.productid = p.productid  , p.activestatus=1    left join dbo.[category] c on p.defaultcategoryid = c.categoryid     left join dbo.[unit] u on p.unitid=u.unitid , u.activestatus=1     p.organizationid = '+ cast(@orgid varchar(15))+'    , ii.activestatus = 1       , p.activestatus = 1      , p.isdisabled = 0      , p.cansale = 1    , ii.inventoryid in (' + @orderlist + ')      group ii.productid, p.name, p.primaryimageid, p.productnumberlabel, p.productnumber, c.name,p.saleprice,u.unitname,u.unitid      having isnull((sum(ii.[quantityonhand]) - sum(ii.[quantitysold])), 0) > 0      order p.productnumber, p.name, c.name ' --exec sp_executesql @sql exec(@sql) end  

and here trying is:

var qu= ii in db.inventoryitems                                                             join p in db.products                                       on ii.productid equals p.productid pgroup                                 mr in pgroup.defaultifempty()                                  join u in db.units                                      on mr.unitid equals u.unitid ugroup                                 ur in ugroup.defaultifempty()                                  join c in db.categories                                      on mr.defaultcategoryid equals c.categoryid cgroup                                 cr in cgroup.defaultifempty()                                 mr.activestatus == 1 && mr.organizationid == orgid && ii.activestatus == 1  

from onwards cant understand how that.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -