Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8951271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:37:29+00:00 2026-06-15T13:37:29+00:00

Quite new to EF, basically i want to convert this SQL query: SELECT PSKU.ProductSKUID,

  • 0

Quite new to EF, basically i want to convert this SQL query:

SELECT     
PSKU.ProductSKUID, 
PSKU.ProductSKUName, 
W.WarehouseID, 
W.WarehouseName, 
SA.SystemAreaName, 
COUNT(SLI.ProductSKUID) AS QTY

FROM         dbo.StockLineItem AS SLI INNER JOIN
                      dbo.ProductSKU AS PSKU ON PSKU.ProductSKUID = SLI.ProductSKUID INNER JOIN
                      dbo.Warehouse AS W ON W.WarehouseID = SLI.WarehouseID INNER JOIN
                      dbo.SystemArea AS SA ON SA.SystemAreaID = SLI.SystemAreaID
WHERE     (SA.SystemAreaID = 1)
AND        W.WarehouseID = @WarehouseID
GROUP BY PSKU.ProductSKUID, PSKU.ProductSKUName, W.WarehouseName, SA.SystemAreaName, W.WarehouseID

To an effective EF statement. This is what i Have so far, my Model class and the method:

 [Serializable]
public class StockReturnMethod
{
    public int ProductSKUID { get; set; }
    public int WarehouseID { get; set; }
    public int LotID { get; set; }
    public string LotName { get; set; }
    public int AreaID { get; set; }
    public string AreaName { get; set; }
    public int BinID { get; set; }
    public string BinName { get; set; }
}


public class DALStockMovement
{

    scmEntitiesPrimaryCon entities = new scmEntitiesPrimaryCon();


    public List<AvailibleStock> AvailibleStockQty(int warehouseID)
    {
        var rows = (from PLA in entities.ProductLocationAssignments
                   from W in entities.Warehouses
                   from SLI in entities.StockLineItems
                   from SA in entities.SystemAreas
                   from PSKU in entities.ProductSKUs


                  where W.WarehouseID == warehouseID
                  select new AvailibleStock() { WarehouseID = W.WarehouseID, ProductSKUID = PSKU.ProductSKUID, ProductSKUName = PSKU.ProductSKUName, WarehouseName = W.WarehouseName, Status = SA.SystemAreaName, QtyUnassigned = SLI.ProductSKUID  }).ToList();
        return rows;
    }

Any Advice to get this to an Effective EF Statement would be appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:37:31+00:00Added an answer on June 15, 2026 at 1:37 pm

    I actually used this tool called Linqer, since I had the SQL
    I just popped it into that tool and it generated the Linq for me.

    Here is what came out:

       var SKUStock = (from sli in entities.StockLineItems
                                where
                                  sli.SystemArea.SystemAreaID == 1 &&
                                  sli.WarehouseID == warehouseID
                                group new { sli.ProductSKU, sli.Warehouse, sli.SystemArea, sli } by new
                                {
                                    ProductSKUID = (System.Int32?)sli.ProductSKU.ProductSKUID,
                                    sli.ProductSKU.ProductSKUName,
                                    sli.Warehouse.WarehouseName,
                                    sli.SystemArea.SystemAreaName,
                                    WarehouseID = (System.Int32?)sli.Warehouse.WarehouseID
                                } into g
                                select new AvailibleStock()
                                {
                                    ProductSKUID = (int)(System.Int32?)g.Key.ProductSKUID,
                                    ProductSKUName = g.Key.ProductSKUName,
                                    WarehouseID = (int)(System.Int32?)g.Key.WarehouseID,
                                    WarehouseName = g.Key.WarehouseName,
                                    Status = g.Key.SystemAreaName,
                                    QtyUnassigned = (int)(Int64?)g.Count(p => p.sli.ProductSKUID != null)
                                }).ToList();
                return SKUStock;
    

    It returns exactly what i need :).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm quite new to android, but basically I want to set up a program
Still quite new to Haskell.. I want to read the contents of a file,
Iam quite new to functions in SQL and I would like to create a
I'm quite new to CSS / HTML, and can't find the cause of this
I'm quite new to developing Android apps. Basically I'm making a webview template to
I am quite new to programming. This is in relation to python. So the
I'm quite new to Caliburn.Micro, so I guess this has a simple answer (or
This is probably a really basic error I'm making, but I'm quite new to
I am quite new to Qt and am in a situation where I want
So I'm quite new to programming in general, so this may be a stupid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.