Click here to Skip to main content
15,920,603 members
Please Sign up or sign in to vote.
2.60/5 (2 votes)
See more:
In my Project I use N-tier architecture. For each User Interface (UI page: .aspx extension )there is a single class. These class inherit different Entity class.
In my Data Filtering Layer I want to pass the object of the UI page and want to check.
So for different page I pass different object to my filtering method. How can I filter different object for different page in same filtering method?
Posted
Updated 24-Sep-13 22:33pm
v4
Comments
ArunRajendra 25-Sep-13 4:49am    
Give an example.

Hi,

As far I can understand that's a problem of tight couple.

What you can do....

C#
public interface IFilterable
{
object Filter();
}


implement the same in you Entity Class and then Call Filter Function from your DataFilter Layer

[Update]

C#
public interface IFilterable
    {        
        object Filter();
    }
    
    public abstract class EntityRepo<T> : IFilterable
    {        
        public virtual object Filter()
        {
            return null;
        }
    }
    public class EmpRepo : EntityRepo<EntityEmp>
    {
        public object Filter()
        {            
            // write your logic
            return new List<EntityEmp>();
        }
    }
    public class EntityEmp : IFilterable
    {
        public int ID { get; set; }
        public string Name { get; set; }
       
    }
    // Data Filter Layer 

    public class FilterData
    {
        public IEnumerable< T> GetFilteredData<T>(IFilterable Fltr)
        {
            return (IEnumerable<T>)Fltr.Filter();
        }
    }


I think it will help you...
 
Share this answer
 
v2
Comments
Tanumay99 25-Sep-13 6:55am    
Please give an example. so that I can understand the filtering process for different object.
assume that different object of different UI page has different property.
Suvabrata Roy 25-Sep-13 7:47am    
goto update section
Tanumay99 26-Sep-13 5:29am    
Thank you
Suvabrata Roy 26-Sep-13 5:40am    
Welcome but why you download voted my answer and if its help you then mark as answer...
Tanumay99 26-Sep-13 6:07am    
ok I accept your solution. I do not give you any down vote. It is visitor acceptance.
Well,

Since C# is an object orientated language, you should be able to parse an entire object as you would parse an type of variable. for example :
C#
void ParseSomething(Object obj)
{
   Form a = null;
   if (obj.GetType() == typeof(Form))
      a = (Form)obj;
   if (a != null)
   {
      Label lbl = a.lblName.Text; //Assuming for a second that lblName is public
   }
}

I hope this is what you meant, or else please provide an example.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900