public EntityResponse <T> ExecuteCommandSingleEntity <T>(SZKingdomRequest request, List <SZKingdomArgument> arguments) where T : new() { EntityResponse <DataTable> response = ExecuteCommand(request, arguments); if (!response.IsSuccess) { return(EntityResponse <T> .Error(response)); } List <T> results = SZKingdomMappingHelper.ReadEntitiesFromTable <T>(response); if (results.Count == 0) { return(EntityResponse <T> .Error(ErrorCode.SZKingdomLibraryNoRecords, string.Format(ErrorMessages.SZKingdom_NoResults, request, string.Join("; ", arguments.Select(p => string.Format("{0} = {1}", p.Name, p.Value)))))); } if (results.Count > 1) { return(EntityResponse <T> .Error(ErrorCode.SZKingdomLibraryError, string.Format(ErrorMessages.SZKingdom_SingleResultExpected, request, string.Join("; ", arguments.Select(p => string.Format("{0} = {1}", p.Name, p.Value)))))); } return(results.Single()); }
public EntityResponse <List <T> > ExecuteCommandList <T>(SZKingdomRequest request, List <SZKingdomArgument> arguments) where T : new() { EntityResponse <DataTable> response = ExecuteCommand(request, arguments); if (!response.IsSuccess) { return(EntityResponse <List <T> > .Error(response)); } List <T> results = SZKingdomMappingHelper.ReadEntitiesFromTable <T>(response); return(results); }