如何获取使用存储库获取的实体的大小? [英] How to get size of entity fetched using repository ?

查看:120
本文介绍了如何获取使用存储库获取的实体的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想得到一个实体类的大小 - 使用Repository从数据库中获取。

如何使用Vb.net这样做?



线下是调用我的InwardService中的GetEntity方法。



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)



那么我想要的大小是 Inward



GetEntity功能的我的服务代码如下 -


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





我的尝试:



到目前为止研究我知道,我可以使用SQL查询实现它 -



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



但我想使用存储库模式1264 KB。任何帮助将不胜感激?


But i want 1264 KB using Repository Pattern. Any help would be appreciated ?

推荐答案

1)创建SQL查询的存储过程

2)添加方法到你的repository,使用table name参数调用所述过程,并将结果作为字符串标量返回。
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.


这篇关于如何获取使用存储库获取的实体的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆