LINQ to SQL数据类 [英] LINQ to SQL dataclass

查看:91
本文介绍了LINQ to SQL数据类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我做了一个LINQ to SQL类.当我使用此类时,我发现一些表显示为普通表,并且可以在其中选择任何字段

其他一些表显示为Entity Set<tablename>,但我无法读取其字段,它在表中显示了诸如add firt和single
之类的方法.
那是什么问题呢?

在此先感谢
Emad

Hi All,

I made a LINQ to SQL class. When I use this class I find some tables appears as normal tables and I can select any field in it

Some other tables appear as Entity Set<tablename> and I can''t read its field it display the methods in the table like add firt and single

So what is the problem?

Thanks in advance
Emad

推荐答案

执行Linq to SQL时,您将获得一个DataContext(类似于数据库),其中包含表(类似于DB表).当您执行dataContext.Products.Where(p => p.Price> 100)时,您将获得实体集(如记录集或子查询).您可以使用循环读取它们,也可以通过执行ToList()将它们转换为List.您不能将新记录添加到子查询.您应该添加到表Products或从表中删除.
When you do a Linq to SQL you get a DataContext (similar to database), which contain tables (similar to DB tables). When you do a dataContext.Products.Where(p=>p.Price>100) you get Entity Set (like record set or sub query). You can read them by using loops or you can convert them to List by doing a ToList(). You can''t add a new record to a sub query. You should add to table Products or delete from it.


这篇关于LINQ to SQL数据类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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