TypedView>StoredProcedure Retrival - Simplify?

Posts   
 
    
hotmail
User
Posts: 47
Joined: 06-Feb-2013
# Posted on: 13-Dec-2017 17:40:51   

Hello, Using LLBL v5.3 latest, SQL Server 2016, adapter.

We use TypedView that are mapped to stored procedure. i wish it was as easy as retrieving DataTable. When you have tons of TypedView the current method is not much desired.

Can you consider making is more simple?

Current Method


        public List<MvListItemRow> GetListItem(string category, int officeId)
        {
            var rv = new List<MvListItemRow>();
            using (var adapter = DataAccessHelper.GetAdapter())
            {
                rv= RetrievalProcedures.FetchMvListItemTypedView(adapter, new QueryFactory().GetMvListItemTypedViewProjection(),category,officeId);
                adapter.CloseConnection();
            }
            return rv;
        }

Preferred Method, something like this


        public List<MvListItemRow> GetListItem(string category, int officeId)
        {
            var rv = new List<MvListItemRow>();
            using (var adapter = DataAccessHelper.GetAdapter())
            {
                rv = RetrievalProcedures.FetchTypedView(category, officeId,adapter);
                adapter.CloseConnection();
            }
            return rv;
        }

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 13-Dec-2017 18:22:52   

You can do the following:


CustomersOnCountryTypedView customersTv = new CustomersOnCountryTypedView();
using(DataAccessAdapter adapter = new DataAccessAdapter())
{
    adapter.FetchTypedView(customersTv, RetrievalProcedures.GetQueryForCustomersOnCountryTypedView("USA"));
}

hotmail
User
Posts: 47
Joined: 06-Feb-2013
# Posted on: 14-Dec-2017 01:53:25   

it doesn't seem to work when i have my "Typed view output type default" as "PocoWithQuerySpecQuery" in settings.

any thoughts?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 14-Dec-2017 17:59:01   

In this case you should use QuerySpec to fetch the TypedView Example:

var results = RetrievalProcedures.FetchCustOrderHistResultTypedView(new QueryFactory().GetCustOrderHistResultTypedViewProjection(), "ALFKI");

Similar to your first example, which makes sense since you are using PocoWithQuerySpec as the output.

If you were using DataTable as the output type, the code to fetch it would be as simple as your second example.

RetrievalProcedures.FetchCustOrderHistResultTypedView(adapter, custOrderHistTv, "ALFKI");