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 995321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:42:18+00:00 2026-05-16T06:42:18+00:00

hello friends i am following 3 layer architecture for my project i mean presentation

  • 0

hello friends i am following 3 layer architecture for my project i mean
presentation layer, business logic layer and finally database layer
my question is that i am making a search feature for my project where i need to send parameter through a method for search query which is to make on business logic layer
i am to send parameter from presentation layer by calling some method and those parameter will be used on business logic layer’s method to make appropriate query
it’s not sure sure how many parameters will be send every time i mean parameters are optional
so my question is that how should i send these optional parameter for getting exactly the require parameter on business logic layer.

What is the best way, i am programming in asp.net

  • 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-05-16T06:42:18+00:00Added an answer on May 16, 2026 at 6:42 am

    If you use business entities, mark every properties by custom attribute with (mask = 1, 2, 4, 8…, required = true/false).

    class Product
    {
    
      [FieldAttribute(Required=true, Mask= 0)] 
      public int Id {get; set;}
    ...
      [FieldAttribute(Required=false, Mask=1)] 
      public string ProductName { get; set;}    
    }
    

    then you can use reflection to read all required properties and pass them to sp. if some not required parameters is null (use Nullable<>) don’t increment mask (mask &= propertyMask).

    Use integer mask to partial update.

    /*
    
        exec dbo.Update_Product @product_id = 1, @quantity = 3, @mask =  0x0004
        exec dbo.Update_Product @product_id = 1, @product_name = 'new name', @comment = 'new comment', @mask =  0x0003
    
    */
    
    
    alter proc dbo.Update_Product
        @product_id int        
        ,@product_name nvarchar(100)    = NULL -- 0x0001
        ,@comment nvarchar(255)         = NULL -- 0x0002
        ,@quantity int                  = NULL -- 0x0004
        ,@mask     int               
    AS    
        update dbo.Product
        SET 
             ProductName    = CASE WHEN (@mask & 0x0001) > 0 THEN @product_name   ELSE ProductName    END
            ,Comment        = CASE WHEN (@mask & 0x0002) > 0 THEN @comment       ELSE Comment        END
            ,Quantity       = CASE WHEN (@mask & 0x0004) > 0 THEN @quantity       ELSE Quantity       END
        WHERE id = @product_id
    

    2) For select, use two masks (select, and where)

    /*
    exec dbo.Select_Product @select_mask = 0x0001, @where_mask = 0
    exec dbo.Select_Product @select_mask = 0x0003, @where_mask = 0
    
    exec dbo.Select_Product @select_mask = 0x0003, @where_mask = 0x0004, @quantity = 2
    
    */
    alter proc dbo.Select_Product
         @select_mask     int 
        ,@where_mask      int 
        ,@product_name nvarchar(100)    = NULL -- 0x0001
        ,@comment nvarchar(255)         = NULL -- 0x0002
        ,@quantity int                  = NULL -- 0x0004
    as
     DECLARE @select varchar(max)
     DECLARE @where varchar(max)
    SET @select = 'select Id '
    
    IF  (@select_mask & 0x0001) > 0
        SET @select = @select + ',ProductName'
    IF  (@select_mask & 0x0002) > 0
        SET @select = @select + ',Comment'
    IF  (@select_mask & 0x0004) > 0
        SET @select = @select + ',Quantity'
    
    SET @select = @select + ' from dbo.Product'
    
    IF @where_mask > 0
        SET @where = ' where ' + CASE WHEN (@where_mask & 0x0001) > 0 THEN 'ProductName = ''' + @product_name  + '''' ELSE ''    END
                + CASE WHEN (@where_mask & 0x0002) > 0 THEN 'Comment = '''  + @comment + ''''  ELSE ''    END
                + CASE WHEN (@where_mask & 0x0004) > 0 THEN 'Quantity = ' + CONVERT(varchar(10), @quantity)   ELSE ''    END
    
    PRINT @select + @where
     exec (@select + @where)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello friends I am getting the following error while making the foreign key 'tbl_course'
Hello friends I am using the following code in my my project. PERMISSIONS: <uses-permission
Hello friends I am using the following code in my my project. PERMISSIONS: <uses-permission
Hello Friends i have the following query which defeat the very purpose. A day
Hello friends I have the following script in my Template: window.addEvent('domready', function () {
Hello friends I am having following table structure of quote Table I want to
Hello Friends I am using the following code to show the amount entered in
hello friends following is my query where displaylist is object if stringBuilder which have
Possible Duplicate: iPhone development on Windows Hello friends, I Want To Know that Is
how to build database structure of language translation system? hello friends.. here i am

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.