**I Need return results of a Stored Procedure
(EXEC SPGetProductsOfCategoryPaginationCompact 6)
Already Mapped this SP in LLBLGen
Adapter Template
**
My Facade Class :: (ErpProdutoCommand)
public static EntityCollection<ErpProdutoStatusEntity> GetListByCategory(int categoryId, bool fetchAllNodes, int results)
{
EntityCollection<ErpProdutoStatusEntity> ret = new EntityCollection<ErpProdutoStatusEntity>();
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
IRetrievalQuery queryResults = RetrievalProcedures.GetSpgetProductsOfCategoryCallAsQuery(categoryId);
using (IDataReader reader = adapter.FetchDataReader(queryResults, CommandBehavior.CloseConnection))
{
while (reader.Read())
ret.Add(ErpProdutoProxy.FetchFullProductStatus(reader));
}
}
return ret;
I'm using this code to Fetch My Procedure (Class::ErpProdutoProxy)
internal static ErpProdutoStatusEntity FetchFullProductStatus(IDataReader reader)
{
/*Required by Inner Join*/
ErpProdutoEntity produto = ErpProdutoProxy.FetchProductRetrievalQuery(reader, 0);
ErpMarcaEntity marca = ErpProdutoProxy.FetchMarcaRetrievalQuery(reader, 12);
ErpProdutoStatusEntity produtoStatus = ErpProdutoProxy.FetchProductStatusRetrievalQuery(reader, 14);
ErpStatusEntity status = ErpProdutoProxy.FetchStatusRetrievalQuery(reader, 22);
/*Left Join*/
VitrineProdutosFotosEntity produtoFoto = ErpProdutoProxy.FetchProductPhotoRetrievalQuery(reader, 24);
VitrineProdutosComplementosEntity produtoComplementos = ErpProdutoProxy.FetchProductComplementsRetrievalQuery(reader, 27);
produtoStatus.ErpProduto = produto;
produtoStatus.ErpStatus = status;
if (produtoComplementos != null)
produtoStatus.VitrineProdutosComplementos = produtoComplementos;
if (produtoFoto != null)
produtoStatus.VitrineProdutosFotos.Add(produtoFoto);
return produtoStatus;
}
And this to any Entities: (Class::ErpProdutoProxy)
internal static VitrineProdutosFotosEntity FetchProductPhotoRetrievalQuery(IDataReader reader, int initialIndex)
{
if (reader.IsDBNull(0 + initialIndex))
return null;
VitrineProdutosFotosEntity foto = new VitrineProdutosFotosEntity()
{
IdFoto = reader.GetInt32(0 + initialIndex),
IdProduto = reader.GetInt32(0 + initialIndex),
Foto = reader.GetValue(0 + initialIndex).ToString()
};
return foto;
}
I want make this with a TypedList? Is Possible?