实体内存使用问题 [英] Entity Memory Usage Problem

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

问题描述

我有一个类似

I have a class like

public SampleClass
{
    public int SampleID
    public int Sample1
    public int Sample2
    .
    .
    .
    public int Samplen

    public string SampleString1
    public string SampleString2
    .
    .
    .
    public string SampleStringn


}



我使用该查询使用较少的记忆而服务器没有困难


I use that query for use less memorry and server doesn't have difficulty

List<sampleclass> sampleList=(from q in context.SampleTable select new SampleClass{SampleID=q.Sample1,Sample1=q.Sample2}).ToList();



我想知道如果使用它与


I wonder that if use that is it same as

List<sampleclass> sampleList=(from q in context.SampleTable select new SampleClass{SampleID=q.Sample1,Sample1=q.Sample2,...,Samplen=q.Samplen,SampleString1=q.SampleString1,...,SampleStringn}).ToList();

推荐答案

如果您有Property1 ... Property< n>等属性你的webmethods返回100,000行然后你已经有很多架构问题。



由于你的属性是整数,它可能会使用相同的内存天气你填充它们或不作为0获取尽可能多的内存存储为1000.如果要传递可选数量的属性,则使用parent \child排列,以便每个父项只有它需要传递的属性。
If you have properties like Property1...Property<n> and your webmethods return 100,000 rows then you already have lots of architectural problems.

As your properties are ints it might use the same memory weather you populate them or not as 0 takes as much memory to store as 1000. If you want to pass an optional amount of properties then use a parent\child arrangement so each parent has only the properties it needs to pass.


除非你有真正的问题,否则不要担心内存。



因为你设置了更多的属性然后你分配更多的内存在第二种情况下,但它再次没什么区别。
Don't worry about memory unless you have a genuine problem with it.

Since you are setting more properties then you are allocating more memory in the second case, but again it will make little difference.


这篇关于实体内存使用问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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