表使用Entity Framework返回的数据 [英] Data returned by tables using Entity Framework

查看:66
本文介绍了表使用Entity Framework返回的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的一个项目中使用Entity Framework。我必须知道通过实体框架的数据是什么。



例如。

考虑我有两个表A(Id,name)和B(id,Aid)。 B在援助栏中引用A.



根据实体框架,我可以访问A到B中的名称,例如=> B.A.name。但是在少数表中,A充满了它的值,而在其他情况下,它是空的。



我的问题是?在上面的情况B.A.name。在什么情况下A将被填充(当我使用对象上下文从数据库获取数据时)以及在什么情况下它不会。?

I am using Entity Framework in one of my projects. I have to know what are the data that are through Entity Framework.

For example.
Consider I have two tables A(Id, name) & B(id,Aid). And B is referencing A in "Aid " column.

According to entity framework I can access the name in A through B for example=> B.A.name. But in few tables A is filled with its value and in other cases it is null.

My question is ?? In above case B.A.name. In what cases the A will be filled (when I use object context to get the data from the Database) and in what cases it wont.?

推荐答案

你有吗?在数据库中为A.id =>设置的外键B.Aid?我假设你这样做。



只要您定义了这种关系,并且您的数据库中有有效数据;你应该总是从B.A.name获取数据。如果你的B中的记录在B.Aid列中有空,那么你唯一不会这样做。



如果你设置正确,我会开始根据您的数据,您能提供一组样本数据吗?
Do you have a foreign key set up in your database for A.id => B.Aid? I assume you do.

As long as you have that relationship defined and you have valid data in your DB; you should always get data back from B.A.name. The only times you would not is if you have records in B that have null in the B.Aid column.

If you have this set up correctly, I would start with your data, can you provide a sample set of your data?


这篇关于表使用Entity Framework返回的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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