简体   繁体   English

实体框架中自动生成的实体的基类类型是什么?

[英]What is the base class type of the auto-generated entities from the Entity Framework?

I'm trying to create a function that takes any table from my ADO.NET Data Model in Silverlight. 我正在尝试创建一个函数,该函数从Silverlight中的ADO.NET数据模型中获取任何表。 I can't figure out what the base class is for the Entity Objects that it creates for me. 我无法弄清楚它为我创建的实体对象的基类是什么。 Each Entity in the model is of this type: 模型中的每个实体都是这种类型的:

global::System.Data.Objects.DataClasses.EntityObject

but that type wasn't working in SilverLight. 但是该类型在SilverLight中不起作用。

I'd like to do something like this: 我想做这样的事情:

   public void foo(WhatGoesHere entityObject)
    {
        //Use entityObject to manipulate the DB
    }

So: What types of Silverlight objects are they? 那么:它们是什么类型的Silverlight对象?

Silverlight is a subset of the dotnet framework. Silverlight是dotnet框架的子集。

I am guessing that Entity Framework is one of the things that is not included in Silverlight. 我猜实体框架是Silverlight中未包含的东西之一。

You could build the system with a WCF service between silverlight and the database. 您可以在silverlight和数据库之间使用WCF服务构建系统。 Your silverlight app talks to the service using WCF, and your service gets data from the database and maps them to data transfer objects to be sent to the silverlight app. 您的silverlight应用程序使用WCF与该服务进行通信,并且您的服务从数据库中获取数据并将其映射到数据传输对象以发送到silverlight应用程序。

That last point with mapping the data will not be required in the next version of Entity Framework, since it uses POCO (Plain Old CLR Objects) 在下一个版本的Entity Framework中,不需要映射数据的最后一点,因为它使用POCO(普通的旧CLR对象)

You could worry about base classes and POCOs and how you're going to manually map object changes and queries into WCF calls, or you could use RIA Services , which are designed to map EF models to Silverlight without fuss and worry. 您可能会担心基类和POCO,以及如何将对象更改和查询手动映射到WCF调用中,或者可以使用RIA Services来将EF模型映射到Silverlight,而不必大惊小怪。 It's still in preview, but the go-live restriction has been removed and this will be by far the easiest solution, even with possible preview bugs. 它仍然处于预览状态,但是上线限制已被删除,即使存在可能的预览错误,这也是迄今为止最简单的解决方案。

RIA Services are explicitly designed for the problem you're presently trying to solve. RIA服务是专门为您当前要解决的问题而设计的。 Don't reinvent the wheel! 不要重新发明轮子!

Just right click on one of your models and select "Go To Definition". 只需右键单击您的模型之一,然后选择“转到定义”。 You can see the class definition from there. 您可以从那里看到类定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 指定Web服务引用自动生成的实体基类 - Specify Web Service Reference Auto-Generated Entity base class 如何在Entity Framework中为自动生成的类添加自定义方法? - How to add custom method to auto-generated class in Entity Framework? 继承自Entity Framework中的自动生成的类 - Inheriting from auto-generated classes in Entity Framework 派生自动生成的实体类 - Derive Auto-Generated Entity Class 循环进入类元数据中的自定义属性(以避免通过实体框架工作图修改自动生成的类) - Looping into custom attributes in class Metadata (to avoid modifying auto-generated class by Entity FrameWork diagram) C#按实体框架向自动生成的表中添加一列 - C# Add a column to Auto-Generated Table by Entity Framework 如何摆脱自动生成模型中的Entity Framework属性? - How to get rid of Entity Framework attributes in auto-generated models? 如何使用实体框架数据库首先自动生成的代码中的接口 - How to use interface from entity framework database first auto-generated code 从实体框架数据库生成接口首先自动生成代码 - Generating Interfaces from entity framework database first auto-generated code 自动生成的实体类中缺少导航属性 - missing Navigation property in auto-generated entity class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM