Quantcast
Channel: CSLA .NET
Viewing all articles
Browse latest Browse all 764

Pass 2 arguments to Dataportal.Fetch

$
0
0

Good day.

i hope that somebody could help me with this. i am needing to pass 2 parameters to the Dataportal.Fetch method. currently i am passing 1 argument which is an enum type, but i am needing to pass a second optional string parameter to fetch NVLList objects. currently i have this method which works well when passing only 1 argument:

public static NVLList GetList(Common.Enums.TextListEnum emListType)
        {
            return Csla.DataPortal.Fetch<NVLList>(emListType);
        }

but i am needing to do something like this:

public static NVLList GetList(Common.Enums.TextListEnum emListType,[Optional]string Pparam)
        {
            //return Csla.DataPortal.Fetch<NVLList>(emListType,Pparam); <- this does not work
        }

 

i have tried this as well which does not give any Intelli errors but fails when running the code:

public static NVLList GetList(Common.Enums.TextListEnum emListType,[Optional]string Pparam)
        {
            return Csla.DataPortal.Fetch<NVLList>(new Criteria(emListType,Pparam));
        }

 private class Criteria
        {
            public Common.Enums.TextListEnum Arg1 { get; private set; }
            public string Arg2 { get; private set; }
            public Criteria(Common.Enums.TextListEnum arg1, string arg2) { Arg1 = arg1; Arg2 = arg2; }
        }

 

the reason that i am needing to pass the second optional parameter is that i am calling NVLList based on an enum which determines what list i am returning, but at times i need to return a list for certain sql queries based on an ID value which is what i would like to pass in the second optional parameter.

 

any help on this would be greatly appreciated.


Viewing all articles
Browse latest Browse all 764

Trending Articles