Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Beat Practice, use the result of SQL Linq as List and get the sums from it, or just use SQL Linq and use a new query

Beat Practice, use the result of SQL Linq as List and get the sums from it, or just use SQL Linq and use a new query

Scheduled Pinned Locked Moved Database
databasecsharplinqquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jkirkerx
    wrote on last edited by
    #1

    So I wrote this SQL Linq that grabs the cart items, which has all the info I need. To keep my functions clean and reusable,I thought maybe I should just standardize Sub Totals and make a class of it it, and add it to each model that requires it, and call the function to populate the values. Just to get an idea of what I'm talking about. I just made the code up below for clarity.

    public class cartitems
    {
    public int cartID { get; set; }
    public decimal totalPrice { get; set; }
    public model_subTotals st { get; set; }
    }

    public class model_subTotals
    {
    public decimal subTotal { get; set; }
    }

    It is good practice for me to populate the first model, and then go back and send the results back into another function as a list to populate the 2nd model? I would be sending the first model back as a list, but I'm not sure if I can work sums on a list or not, never done it before. Or if I should just make a new query, and attach the result to the list.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups