Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get a size of Entity Class - which is fetched from database using Repository.
How to do so using Vb.net ?

Below Line is calling GetEntity Method which is in my InwardService.

Dim Inward As ARI.PurchaseTranEntity.InwardOutward = _InwardService.GetEntity(id)

So what i want to get the size is of Inward ?

My Service Code For GetEntity Function is as Follows -
Public Overrides Function GetEntity(code As Integer) As ARI.PurchaseTranEntity.InwardOutward
Try
Dim Data = Repository.Query(
                 Function(c) c.Code = code).
                       Include(Function(c) c.InwardOutwardDetails).
                       Include(Function(c) c.AdditionalChargesDetails).
                           Include(Function(c) c.AdditionalChargesDetails.Select(Function(k) k.AdditionalChargesAccount)).
                       Include(Function(c) c.NoteDetails).
                       Include(Function(c) c.AttributeValues).
                       Include(Function(c) c.BusinessPartner).
                       Include(Function(c) c.Currency).
                       Include(Function(c) c.Buyer).
                       Include(Function(c) c.BillToAddress).
                       Include(Function(c) c.ShipToAddress).
                       Include(Function(c) c.Shipper).
                       Include(Function(c) c.PriceList).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.ProductTaggingDetails)).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.ProductTaggingDetails.Select(Function(y) y.Product))).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.UOM)).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.Item).Select(Function(d) d.ItemBarCodeLinks)).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.Item)).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.StockPoint)).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.Tax)).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.Buyer)).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.InwardOutwardAllocationDetails)).
                       Include(Function(c) c.InwardOutwardDetails.Select(Function(x) x.RequisitionFulfillmentDetails)).
                       Select(Function(c) c).SingleOrDefault()
Catch ex As Exception
           Throw ex
       End Try
   End Function


What I have tried:

So far by researching i got to know that , i can achieve it using SQL Query -
SELECT *
INTO dbo.MyTempTable
FROM stmItem
exec sp_spaceused 'Table'
DROP TABLE Table

Above Query is returning required Output -
name	         rows	reserved	data	index_size	unused
Table	         8978     1296 KB	1264 KB	  8 KB	     24 KB

But i want 1264 KB using Repository Pattern. Any help would be appreciated ?
Posted
Updated 13-Feb-19 5:15am
Comments
Richard Deeming 14-Feb-19 10:36am    
Catch ex As Exception
    Throw ex


Don't do that! You've just destroyed the stack track of any exception thrown, making it much harder to track down the real cause.

If you must re-throw an exception, just use Throw instead of Throw ex.
Throw Statement (Visual Basic) | Microsoft Docs[^]

But in this case, since you're not doing anything with the exception, you can just remove the Try..Catch block entirely.

1 solution

1) Create a stored procedure of your "SQL Query"
2) Add a method to your "repository" that calls said procedure with a "table name" parameter and return the result as a string scalar.
 
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