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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Linq to SQL

Linq to SQL

Scheduled Pinned Locked Moved ASP.NET
questioncsharpdatabaselinq
5 Posts 2 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.
  • S Offline
    S Offline
    Satish_S
    wrote on last edited by
    #1

    using (apReportDataContext context = new apReportDataContext())
    {
    var appointments = (
    from app in context.t_msts
    join li in context.Lead_In
    on app.apm_LeadID equals li.iLeadID into app_li
    from li in app_li.DefaultIfEmpty()
    join cs in context.custContactInfos on li.iLeadID equals cs.id into li_cs
    from cs in li_cs.DefaultIfEmpty()
    join apm in context.atm_appointment_type_masts on app.apm_type_id equals apm.atm_id into cs_apm
    from apm in cs_apm.DefaultIfEmpty()

                            select new
                            {
                              app.apm\_id,
                              app.apm\_name,
                              app.apm\_desc,
                              app.apm\_start\_time,
                              cs.CustomerName,
                              apm.atm\_type\_name,
                              
                            });
    
              
    
    
    
    
                grv.DataSource = appointments.Distinct();
                grv.DataBind();
    
            }
    

    this is generating me result as expected now i need to pass paameters to this when generate report button is clicked, i have a drop down and if drop down value !=0 then i have to pass the value of it and if another text box field is filled then i have to pass that also as a parameter how can i do this?

    D 1 Reply Last reply
    0
    • S Satish_S

      using (apReportDataContext context = new apReportDataContext())
      {
      var appointments = (
      from app in context.t_msts
      join li in context.Lead_In
      on app.apm_LeadID equals li.iLeadID into app_li
      from li in app_li.DefaultIfEmpty()
      join cs in context.custContactInfos on li.iLeadID equals cs.id into li_cs
      from cs in li_cs.DefaultIfEmpty()
      join apm in context.atm_appointment_type_masts on app.apm_type_id equals apm.atm_id into cs_apm
      from apm in cs_apm.DefaultIfEmpty()

                              select new
                              {
                                app.apm\_id,
                                app.apm\_name,
                                app.apm\_desc,
                                app.apm\_start\_time,
                                cs.CustomerName,
                                apm.atm\_type\_name,
                                
                              });
      
                
      
      
      
      
                  grv.DataSource = appointments.Distinct();
                  grv.DataBind();
      
              }
      

      this is generating me result as expected now i need to pass paameters to this when generate report button is clicked, i have a drop down and if drop down value !=0 then i have to pass the value of it and if another text box field is filled then i have to pass that also as a parameter how can i do this?

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      You need to use where keyword here. It behaves same as the where clause in the SQL statements. Something like this:

      from element in someIEnumerable
      where element.property == someValue
      select element

      S 1 Reply Last reply
      0
      • D dan sh

        You need to use where keyword here. It behaves same as the where clause in the SQL statements. Something like this:

        from element in someIEnumerable
        where element.property == someValue
        select element

        S Offline
        S Offline
        Satish_S
        wrote on last edited by
        #3

        thanks for your reply yes what you said is working but if suppose user not entering value of text box then the value will be empty, this will give error, i need to check as this for 5 input controls, and if a control value is not empty then i have to pass that one as a parameter. how to do this.

        D 1 Reply Last reply
        0
        • S Satish_S

          thanks for your reply yes what you said is working but if suppose user not entering value of text box then the value will be empty, this will give error, i need to check as this for 5 input controls, and if a control value is not empty then i have to pass that one as a parameter. how to do this.

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          If those values are mandatory, use RequiredFieldValidator. If not, then you will have to check for the null values. Since I do not know the exact scenario in your application, cannot provide any better solution.

          S 1 Reply Last reply
          0
          • D dan sh

            If those values are mandatory, use RequiredFieldValidator. If not, then you will have to check for the null values. Since I do not know the exact scenario in your application, cannot provide any better solution.

            S Offline
            S Offline
            Satish_S
            wrote on last edited by
            #5

            Thanks again for your reply .. finally i got a solution and i have done it as below.

            using (apReportDataContext context = new apReportDataContext())
            {
            var appointments = (
            from app in context.t_msts
            join li in context.Lead_In on app.apm_LeadID equals li.iLeadID into app_li
            from li in app_li.DefaultIfEmpty()
            join cs in context.custContactInfos on li.iLeadID equals cs.id into li_cs
            from cs in li_cs.DefaultIfEmpty()
            join apm in context.atm_appointment_type_masts on app.apm_type_id equals apm.atm_id into cs_apm
            from apm in cs_apm.DefaultIfEmpty()
            select new
            {
            app.apm_id,
            app.apm_name,
            app.apm_desc,
            app.apm_start_time,
            cs.CustomerName,
            apm.atm_type_name
            }
            );

            **

            if (dropdown.SelectedIndex != 0) appointments=
            apps.Where(ap => ap.apm_ID.Equals(dropdown.SelectedValue));

            **grv.DataSource = appointments.Distinct(); grv.DataBind();

            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