2013年12月27日星期五

How to Market Yourself Online

How to Market Yourself Online

Building Business Applications with Microsoft Silverlight

 Building Business Applications with Microsoft Silverlight
Microsoft Corporation – April 2010

http://download.microsoft.com/download/7/C/8/7C87A1AE-E500-471F-91C9-EA289360C12C/Building%20Business%20Apps%20with%20Silverlight.docx

2013年12月25日星期三

.Net开发者必备的11款开发利器

日期:2012-4-26
导读:如今,HTML5,jQuery,JavaScript等等这些热门技术,受到了开发者们的强烈追捧,有了这些开发工具也为开发者们减轻了许多负担。本文为开发者介绍了11款.NET框架。

Web开发工具选择和使用调查报告- 2011.8

结果概要
1 开发语言选择
1.1 PHP、ASP/ASP.NET、Java及相关语言,都具有广泛的应用性。
1.2 Java及其相关开发语言在不同规模开发团队的应用存在较大差别。

2013年12月24日星期二

Announcing the Release of Visual Studio 2013 and Great Improvements to ASP.NET and Entity Framework

Announcing the Release of Visual Studio 2013 and Great Improvements to ASP.NET and Entity Framework

Today we released VS 2013 and .NET 4.5.1. These releases include a ton of great improvements, and include some fantastic enhancements to ASP.NET and the Entity Framework.  You can downloadand start using them now.
Below are details on a few of the great ASP.NET, Web Development, and Entity Framework improvements you can take advantage of with this release.  Please visit http://www.asp.net/vnext for additional release notes, documentation, and tutorials.

使用ASP.NET MVC3+EF+Jquery制作文字直播系统

昨天刚刚完成了学校六十校庆上用的文字直播系统,当然不是使用MVC做的。今天我再使用ASP.NET MVC3+EF+JQuery完善一下这个系统,也作为Entity Framework 4 in Action读书笔记系列前期的一个例子吧。

About Technical Debates (and ASP.NET Web Forms and ASP.NET MVC debates in particular) - ScottGu's Blog


Technical debates are discussed endlessly within the blog-o-sphere/twitter-verse, and they range across every developer community. Each language, framework, tool, and platform inevitably has at least a few going on at any particular point in time.

ASP.net MVC Vs ASP.net Web Form

ASP.net MVC Vs ASP.net Web Form

Software Architects have been involving lot of debates about different approaches and architectures. Some of the examples are ORM Vs Store Procedures, REST Vs SOAP, etc. There is a debate happening inside the Microsoft community about ASP.net web form Vs ASP.net MVC. Many people thinking that ASP.net MVC will be replace webforms at least eventually and others are thinking that ASP.net MVC will not be replace webforms. Will ASP.net MVC replace webforms?. ASP.net MVC is an alternative approach to webforms rather than a replacement. It will not replace webforms and webforms will not replace ASP.NET MVC. The fact is that ASP.NET MVC and webforms will co-exist and that ASP.NET MVC is not a replacement for webforms. If you prefer ASP.net MVC use it and you feel webform is more comfortable, you can use it. . Both approaches are just choices and different approaches and choices are good things. Different choices are available for other platforms especially in the Java platform.

The Future of WebForms And ASP.NET MVC

I’ve heard a lot of concerns from people worried that the ASP.NET team will stop sparing resources and support for Web Forms in favor of ASP.NET MVC in the future. I thought I would try to address that concern in this post based on my own observations.

Should you return IQueryable from Your Repositories

    Should you return IQueryable<T> from Your Repositories
    Posted a year ago by Alex Ford (edited a year ago)

DomainContext and Operations

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Comparing WCF Data Services and WCF RIA Services

Windows Communication Foundation (WCF) provides all the support you need to build distributed 

使用Entity Framework和WCF Ria Services开发SilverLight

使用Entity Framework和WCF Ria Services开发SilverLight之1:简单模型


本文目的是通过Silverlight ria service完成一次数据的读取过程,并且在此基础上建立测试项目。
Ria service借助于WCF和ADO.NET Entity Framework构建分布式开发框架。使用它可以快速构建自己的开发模式。

2013年12月23日星期一

Walkthrough: Taking a Tour of RIA Services

Walkthrough: Taking a Tour of RIA Services


使用MEF+MVVM light+WCF RIA Service实现的Sellthrough系统

在csdn上承诺要分享一个使用Silverlight+MVVM+MEF实现一个项目,都过去一个月了,我还没开始。。。

Silverlight使用WCF RIA SERVICE实现CUD

这篇文章主要是使用WCF RIA SERVICE实现对数据的新增,更新,删除(CUD)。 

WCF序列化65536大小限制的问题

在Silverlight+WCF RIA Service或者WCF Service的架构中,经常会遇到WCF序列化65536大小限制的问题。由于WCF RIA Service没有提供明确的异常信息和错误信息,所以往往构成误导。

Silverlight + RIA Service的SUID的实例

WCF RIA Service网上也有一些例子,不过都比较简单,我把我的一个比较接近实际的例子跟大家分享分享。

Silverlight WCF RIA Services: Strategies for handling your Domain Context

This is the first in a two-part article series on the WCF RIA Services Domain Context.
This article series is accompanied by source code, which can be downloaded here.

Async Validation with RIA Services

Almost a year ago, I posted a lengthy article on how to implement Async Validation with RIA Services and DataForm.  It was hard; much harder than it should have been, and we all knew it.  Since then, things have changed, and async validation is a lot simpler.  Let’s take a look at why it’s easier and how you can easily perform async validation in your application.

RIA Services Validation: ViewModel Validation with Entity Rules

For those of you familiar with the ViewModel (or MVVM) pattern, you are likely also familiar with a typical pain point regarding validation: you often need to duplicate your entity validation metadata onto your ViewModel classes.  This can lead to burdensome dual maintenance of your validation rules, and it can seem very frustrating that with the server to client metadata propagation that RIA Services offers, your ViewModel classes are left dangling out there for you to manage yourself.  In this post, I’ll illustrate a utility I created that allows a ViewModel to assume validation metadata from model classes or properties, eliminating the dual maintenance.

RIA Services Validation: Using ValidationContext (Cross-Entity Validation)

In our last post, we learned how ValidationContext can be used to provide and consume state and services for validation methods to use.  Now, let’s take a quick look at how validation methods can actually use this information.  I’m going to include a bunch of code in this post, and I will rely on the code to be rather self-explanatory.

RIA Services Validation: Providing ValidationContext

Throughout this series on RIA Services Validation, I’ve mentioned and shown ValidationContext several times.  In this post, we’ll learn about the purpose of ValidationContext, what types of context it can provide, and how it integrates with RIA Services.  This will allow us to explore further topics such as cross-entity validation and open the door for other advanced validation scenarios.

RIA Services Validation: Entity-Level Validation

In my last post, I went over some cross-field validation scenarios and provided some sample code, including a CompareValidatorAttribute.  We’ve now covered single-field validation and cross-field validation, but there’s yet another level of validation supported by RIA Services—Entity-Level validation.  As you’ll see in this post, entity-level validation is very similar to what we’ve already seen.

RIA Services Validation: Cross-Field Validation

I frequently hear questions about how to perform cross-field validation in RIA Services.  Before thoroughly covering this topic*, I wanted to be sure to go through some simple scenarios, show how to use CustomValidationAttribute, how to derive from ValidationAttribute, explain how validation rules are propagated to the client, and what triggers the validation.  Hopefully by now, you’re getting pretty comfortable with the validation framework and you’re ready to explore some more examples.

RIA Services Validation: Validation Triggers

My goal with this blog post series is to provide an end-to-end tour of how RIA Services validation works and how you can leverage its capabilities to build rich, responsive applications.  A key factor for making the most of validation is fully understanding when and how RIA Services invokes your validation rules.  Awareness of the various validation triggers will help you implement your validators so they are fired as you expect, when you expect.  In this post will dig into the RIA Services codebase and identify every place where entity validation is invoked.

RIA Services Validation: Custom Reusable Validators

We just covered Custom Validation Methods, where we learned how to use CustomValidationAttribute to invoke a static (VB: Shared) method to perform validation.  Let’s talk about an alternate approach to custom validation though: creating custom, reusable validators by deriving fromValidationAttribute.  While it’s true that the custom validation methods used by [CustomValidation] could certainly be reusable, I tend to think of that approach as a light-weight way to call specific business logic routines for validation.  The approach we’re about to see is what I use when I’m creating an inventory of validators to be reused throughout my project(s).

RIA Services Validation: Custom Validation Methods

In our last installment, we learned about the standard validators that ship in the System.ComponentModel.DataAnnotations assembly.  RequiredAttribute, RangeAttribute, StringLengthAttribute, and RegularExpressionAttribute all derive from ValidationAttribute and cover many common validation scenarios.  Every system has its own business rules though, and therefore it’s imperative that RIA Services allows you to create custom validators to implement your own logic.  Moreover, your custom error messages must plug into the same framework that powers the standard validators.  To address this requirement, we added CustomValidationAttribute.

RIA Services Validation: Standard Validators

RIA Services offers powerful features for flowing validation from your entity model all the way up to the Silverlight UI.  In fact, flowing your validation rules from the server into your form controls was one of the primary tenets of RIA Services V1, and our team did the work of getting validation integrated deeply into Silverlight, long before RIA Services was released.  In this post we’ll take a look at the standard validators that are offered.

RIA Services Validation: Attribute Propagation

Since the beginning of the RIA Services project, a primary tenet was to propagate validation rules defined on the server up to the client, integrating the validation directly into the Silverlight UI.  This came to fruition with RIA Services v1.0 and you can in fact apply an attribute to your model on the server and automatically get instant client-side validation of data entry on even the simplest of Textbox controls.  In fact, some validation rules are inferred from your data model directly.  This is a feat that many other frameworks have attempted to accomplish, but I believe RIA Services has one of the most successful implementations of the concept.  In this post, we’ll examine how attributes declared on your model are propagated to the client.  By understanding what is going on behind-the-scenes, you’ll be able to better leverage validation capabilities.

.NET RIA Services... and Beer!

Like most .NET Developers, I do a lot of Line of Business application programming, and I’m very excited about .NET RIA Services. In this (very long) blog post, I’ll update my Beer DB Demo using  .NET RIA Services and the Silverlight Business Application Template. In the past, I’ve used the Beer DB for several talks and demos, including a Silverlight 1.1 Alpha Demo named Andy’s Fridge, and a Silverlight and LINQ to SQL demo.

Performance tips for RIA Service with Silverlight 4

Performance is a vital part for any application possibly more important for web based app.With wizard based approach of RIA service generally we tends to comprise all entities, exposing to the client and also allowing the DomainService to go for everything from the database. Not only this approach takes a toll on security, but also it loads the middle tier unreasonably.
So this post is about few tips using which we can improve the performance. Well mostly we will cover the Pagination, Limiting Query results and Output cache of the results.

How SubmitChanges works in .NET RIA Servies

How SubmitChanges works in .NET RIA Servies

Getting Started - WCF RIA Services

The sample provides a step by step guide to building your first RIA services application. The application we will be building here is an HR Application for an Enterprise.

WCF RIA Services Part 10 - Exposing Domain Services To Other Clients

This article is the tenth and final part of the series WCF RIA Services.

WCF RIA Services Part 9 - Structuring Your Application

This article is Part 9 of the series WCF RIA Services.

WCF RIA Services Part 8 - Testing and Debugging

This article is Part 8 of the series WCF RIA Services.

WCF RIA Services Part 7 - Authentication and Authorization

This article is Part 7 of the series WCF RIA Services.

WCF RIA Services Part 6 - Validating Data

This article is Part 6 of the series WCF RIA Services.

WCF RIA Services Part 5 - Metadata and Shared Classes

This article is Part 5 of the series WCF RIA Services.

WCF RIA Services Part 3: Updating Data

This article is Part 3 of the series WCF RIA Services.

WCF RIA Services Part 2: Querying Data

This article is Part 2 of the series WCF RIA Services.

WCF RIA Services Part 1: Getting Started

This article is Part 1 of the series WCF RIA Services.

WCF RIA Services Part 4 - Integrating with the Model-View-ViewModel Pattern

This article is Part 4 of the series WCF RIA Services.

[译]WCF RIA Services中的集合 - 紫色永恒 - 博客园

Walkthrough: Using Authentication Service with Silverlight Business Application

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Refresh the cached EntitySet after a SubmitChanges – WCF RIA Services

There is a discussion about WCR RIA Services and how to update an EntitySet after a Submit changes, on the Silverlight forum. If we loads a set of entities they will be cached in an EntitySet on the client-side, so 

2013年12月20日星期五

Entity Framework 4.1 and Poco 使用存储过程联表查询

一:数据库支持
为了演示本例,我们创建了另外一个简单的示例数据库MiniNW,该数据库来自于ADO.NET Entity Framework Extensions,但在本例中,我们不会使用这个针对EF的扩展框架,因为它对POCO的支持不好,同时它也不支持DbContext,简单的说来就是它目前不支持EF4.1。

EF 4.2 Model & Database First演示

一、创建应用程序

为了使问题简单,我们建立一个基本的控制台应用程序,使用DbContext执行数据访问:
1. 打开Visual Studio 2010
2. File -> New -> Project…
3. 从左侧菜单中选择"Windows",然后选择"Console Application"
4. 输入"ModelFirstSample"作为名字
5. 选择"OK"

EF 4.2 Code First 演示

这篇文章介绍Code First开发以及如何与DbContext API一起使用。Code First允许使用C#或VB.NET类定义模型,在类或属性上有选择性的执行额外的配置或者使用Fluent API。模型可用于生成数据库架构或映射现有的数据库。
本次演示需要安装Visual Studio 2010。

【开篇导航】—Entity Framework实例详解

一、前言
浏览ADO.NET博客发现,在过去的几年,Entity Framework取得了显著进展,尤其这一两年更是发展迅猛。EF4.1引进了新的DbContext APICode First的支持。今年早些时候发布的EF 4.3提供了对Code First迁移的支持,这使得开发人员可以轻松通过优化代码来改进数据库架构。现在EF5也已经发布并且开源,新版本增加了对枚举、空间数据类型、表值函数的支持和对一些重要性能与Visual Studio工具的改进。EF6将作为Entity Framework的下一个重大版本,计划实现基于任务的同步、Code First中的存储过程和函数的支持以及自定义Code First约定。

【工欲善其事必先利其器】—Entity Framework实例详解

开始本篇文章之前,先说一下Entity Framework 6 Alpha1在NuGet中已可用,原文链接http://blogs.msdn.com/b/adonet/archive/2012/10/30/ef6-alpha-1-available-on-nuget.aspx
俗话说:“工欲善其事必先利其器”,在深入讲解Entity Framework之前,先准备一下开发工具以及前期的配置。

【配置属性】—Entity Framework实例详解

Entity Framework Code First的默认行为是使用一系列约定将POCO类映射到表。然而,有时候,不能也不想遵循这些约定,那就需要重写它们。重写默认约定有两种方式:Data Annotations和FluentAPI。Data Annotations在功能上是Fluent API的子集,在一些映射场景下使用Annotations不能达到重写的目的,因此本篇文章中使用Fluent API配置属性。

【配置关系】—Entity Framework实例详解

实体间的关系,简单来说无非就是一对一、一对多、多对多,根据方向性来说又分为双向和单向。Code First在实体关系上有以下约定:
1. 两个实体,如果一个实体包含一个引用属性,另一个实体包含一个集合属性,Code First默认约定它们为一对多关系。 
2. 两个实体,如果只有一个实体包含一个导航属性或一个集合属性,Code First也默认约定它们是一对多关系。 
3. 两个实体分别包含一个集合属性,Code First默认约定它们为多对多关系。 
4. 两个实体分别包含一个引用属性,Code First默认约定它们为一对一关系。 
5. 在一对一关系情况下,需要提供给Code First额外的信息,以确定它们的主从关系。 
6. 在实体中定义一个外键属性,Code First使用属性是否为空来确定关系是必须还是可选。

【配置映射】—Entity Framework实例详解

前两篇博文中的配置属性和配置关系都是配置映射,配置属性是属性的映射,配置关系式关系的映射,本篇从讲讲实体的映射。
首先,配置实体映射到表,使用ToTable方法,它接受两个参数,第一个参数是表的名称,第二个参数是Schema名称。

【查询】—Entity Framework实例详解

Entity Framework 查询使用集成查询,简称LINQ。LINQ是一个查询框架,并不限于Entity Framework使用,同样不限于数据库。LINQ Provider 负责将LINQ查询翻译成对数据的查询,然后返回查询结果。Entity Framework的LINQ Provider是LINQ to Entities,它将LINQ查询翻译成目标数据库的SQL查询语句。
除了LINQ,Entity Framework还支持基于文本的查询Entity SQL,简称ESQL。ESQL通常使用在需要动态构造查询的情况下。由于ESQL不常用,没有直接暴露在DbContext API。如果需要使用ESQL,需要使用IObjectContextAdapter接口访问ObjectContext API。

Entity Framework 4 in Action读书笔记——第八章:EF处理并发和事务:了解并发问题

本章内容包括
理解并发问题
配置并发
处理并发异常
处理事务
假设你想在网上订机票。查询你的航班,发现还有座位,但是当你单击预订按钮时,系统提示机票已售罄。如果再次查询该航班,发现已经没有座位了。这是怎么回事呢?原来是在你查询到结果和预订之间,其他人预订了最后一张票。系统对最后一张票进行了并发查询,如果没有并发检查,该航班的机票就会超额预订。
本章将深入并发和事务处理。现在我们先来了解什么是并发问题。

Entity Framework 4 in Action读书笔记——第七章:持久化对象到数据库:持久化的一些技巧

7.4 持久化的一些技巧

持久化过程中的很多东西都有可能引起错误,如字符串太长,违反外键约束,不为空的列设置为null,重复键等等。这些都是引发异常的典型原因。让我们看看如何在代码中处理这些异常吧。

Entity Framework 4 in Action读书笔记——第七章:持久化对象到数据库:持久化实体关系图

7.3 持久化实体关系图

持久化order涉及对多个实体的操作。尽管只更新order和它的details,但是order的customer和details中的products作为只读数据同样会被涉及到。因为涉及到多个实体,我们就要谈谈实体关系图(entities graph)或者对象关系图(objects graph)。

Entity Framework 4 in Action读书笔记——第七章:持久化对象到数据库:持久化修改的实体到数据库

7.2 持久化修改的实体到数据库

持久化单个实体到数据库有三种方式:
  • 持久化为一个新行。
  • 使用属性更新一个存在的行。
  • 使用键值属性(key properties)删除一个存在的行。

Entity Framework 4 in Action读书笔记——第七章:持久化对象到数据库:使用SaveChanges持久化实体

本章内容包括
持久化修改的对象到数据库
持久化复杂对象图到数据库
带有外键和独立关联的持久化
本章,我们讨论如何在连接和断开连接的情况下插入、更新和删除实体。包括单个对象的更新,例如一个customer和复杂关系图的更新,例如一个order和它的details。本章结束的时候,你就可以使用EF处理更新了。
让我们开始讨论持久化过程是如何工作的吧。

Entity Framework 4 in Action读书笔记——第六章:理解实体的生命周期(三)

objectstatemanager更改跟踪管理

ObjectStateManager组件(从现在开始称之为 state manager)负责与上下中对象追踪有关的一切:
1.当添加,附加到上下文或者从上下文中删除一个实体,实际上是对state manager做的这些。 
2.当我们说上下文保留从数据库中读取的所有实体集合在内存中时,其实是state manager保存这些数据。 
3.当上下文执行一个身份地图(identity-map)检查,其实是state manager执行的检查。 
4.当我们说上下文跟踪实体间关系式,其实是state manager在跟踪。

Entity Framework 4 in Action读书笔记——第六章:理解实体的生命周期(二)

管理实体状态

上下文仅仅自动处理Unchanged状态到Modified状态的转变。其他的状态转变必须使用适当的方法显示处理:

Entity Framework 4 in Action读书笔记——第六章:理解实体的生命周期(一)

本章内容包括:
  • 理解实体状态
  • 理解状态的转换
  • 自动和手动改变状态
我们先从分析实体的生命周期和它的状态开始。

Entity Framework 4 in Action读书笔记——第五章:域模型映射(Domain model mapping)(三)

映射继承

OrderIT使用两种继承策略:每个层次结构一张表(table per hierachy(TPH))每个类型一张表(table per type(TPT))。数据库不支持继承,但是使用这些继承策略,可以模拟这一行为。我们先从TPH策略开始。

Entity Framework 4 in Action读书笔记——第五章:域模型映射(Domain model mapping)(二)

在模型中定义关系

在OrderIT模型中,有三种类型的关联:one-to-one,one-to-many和many-to-many。

One-to-one 关系

one-to-one关系的典型例子是订单详细(order detail)和订单(order)。创建这种类型的关联一点也不困难,但是涉及几个步骤:
1. 通过添加导航属性修改OrderDetail类。如果选择外键关联,还必须加上外键属性。 
2. 修改CSDL将属性添加到类描述并引入关系。 
3. 修改存储模式(storage schema)引入表之间的外键(如果存在)。 
4. 修改映射模式(mapping schema)映射关系(只对独立关联)。
下面让我们看一下每个步骤。

Entity Framework 4 in Action读书笔记——第五章:域模型映射(Domain model mapping)(一)

本章内容包括:
  • 介绍EDM(Entity Data Model)
  • 创建EF域模型类
  • 描述类
  • 描述数据库
  • 映射类到数据库
首先,让我们讨论一下EDM。

Entity Framework 4 in Action读书笔记——第四章:使用LINQ to Entities查询:预先加载和延迟加载

4.9 加载(Fetching)

预先加载指在一个查询中加载所有的实体和关联的数据。延迟加载指使用时再加载关联的实体。预先加载是检索数据最高效的方法。尽管它从数据库中检索所有的数据,但是只访问一次数据库,避免了延迟加载与数据库的频繁通信。

Entity Framework 4 in Action读书笔记——第四章:使用LINQ to Entities查询:执行手动查询

4.8 执行手动查询

有很多原因决定你会手动写查询。或许由EF生成的SQL太慢,又或许执行起来浪费了太多资源。另一种情况可能是当你动态生成一个如此复杂的查询,创建SQL代码比使用LINQ to Entities简单。

Entity Framework 4 in Action读书笔记——第四章:使用LINQ to Entities查询:使用函数

4.7 使用函数

扩展LINQ to Entities查询的简便方法就是使用函数。有四种类型的函数可以应用:
规范函数—LINQ to Entities本身没有提供的一组预定义的函数。
数据库函数—一组预定义的SQL Server函数。
模型中定义的函数—存储在EDM中的用户定义的实体SQL函数。
自定义数据库函数—可以在查询中使用的用户定义的数据库函数。

Entity Framework 4 in Action读书笔记——第四章:使用LINQ to Entities查询:继承查询

继承引入了多态查询的概念。这种类型的查询认为继承层次结构和返回的对象可能是不同类型,但是继承自相同的基类。
假设你想查询所有的产品。从多态查询获得的是Product对象列表,但具体的类型是Shirt或者Shoe,因为引擎自动实例化为正确的类型。你不仅可以自动得到正确的类型,还可以根据类型应用过滤。例如,你可以只查询鞋子或者只查询衬衫。

Entity Framework 4 in Action读书笔记——第四章:使用LINQ to Entities查询:排序和连接数据

4.4排序(Sorting)

基本需求:用户想数据根据送货城市和邮政编码排序。
解决方案:知道LINQ有一个扩展方法可以根据一个或多个属性排序你一定会很高兴。LINQ to Entities提供了这个方法的实现也一点也不奇怪。在C#中,使用orderby子句。这个子句接受要根据排序的属性。默认情况下,是升序,但是可以在属性后边加上关键字descending实现降序。如果有多个属性是降序,你可以在每个属性后边都加上descending关键字。如SQL中,尽管默认是升序,你依然可以使用ascending指定。下面是例子。

Entity Framework 4 in Action读书笔记——第四章:使用LINQ to Entities查询:分组数据

4.3 分组数据

基本需求:根据送货城市分组返回所有订单。
解决方案:在查询中使用group ... by ...子句。
var result = from c in ctx.Orders
             group c by c.ShippingAddress.City;

Entity Framework 4 in Action读书笔记——第四章:使用LINQ to Entities查询:投影结果

4.2 投影结果

基本需求:用户只想查看订单日期和送货地址
解决方案:为每个订单提取出所有的数据浪费资源,在本例中,仅仅需要一部分数据,你需要的是订单的投影。

Entity Framework 4 in Action读书笔记——第四章:使用LINQ to Entities查询:筛选数据

本章所有的例子都是在第二章OrdeIT结构的基础上完成的。

4.1 筛选数据

基本需求:根据送货城市查询订单。
解决方案:使用LINQ的Where方法添加过滤功能。下面代码查询送货到New York的所有订单。
var orders = from o in ctx.Orders 
             where o.ShippingAddress.City == "New York" 
             select o;

Entity Framework 4 in Action读书笔记——第三章:查询对象模型基础(2)

三、对类进行查询
因为数据库对EDM是完全抽象的,你可以完全忽略底层的数据库结构对类进行查询。EF使用映射信息转换查询成SQL。工作流如下:
image

Entity Framework 4 in Action读书笔记——第三章:查询对象模型基础(1)

本章要点:


1.EF查询技术。
2.捕捉生成的SQL。
3.深入理解EF查询引擎。
4.常见的查询陷阱。

Entity Framework 4 in Action读书笔记——第二章:开始Entity Framework之旅(3)

这篇我们解决两个问题,一是组织产生的代码,而是完成我们的程序,实现基本的功能。
组织产生的代码
默认情况下,设计器产生一个文件,把所有代码都放到这一个文件中。这个文件以设计器文件的名字命名,扩展名为.vb 或 .cs,根据语言的不同。例如,model.edmx设计器文件创建了一个model.edmx.vb或者model.edmx.cs。如果查看一下代码,就会发现很乱。所有的类都放在一个文件中,还有很多属性和方法。更糟糕的是,类都继承自EntityObject,类之间的关系使用EntityCollection<T>和EntityReference<T>表示。下面就介绍一种有效组织代码的方法:the plain old CLR object(POCO)法。

Entity Framework 4 in Action读书笔记——第二章:开始Entity Framework之旅(2)

这一篇我们就来构建我们的应用程序。
一、创建程序集
1.在VS2010中,创建一个空的解决方案,命名为OrderIT。
2.在解决方案中添加一个类库项目,命名为OrderIT.Model,同时添加引用System.Data.Entity。
3.在解决方案中再添加一个ASP.NET MVC 3应用程序项目,添加OrderIT.Model的应用。

Entity Framework 4 in Action读书笔记——第二章:开始Entity Framework之旅(1)

本章我们来看一个经典的订单应用程序“OrderIT”,它管理产品、订单、顾客的信息等。

Entity Framework 4 in Action读书笔记——第一章:数据访问重载:Entity Framework(3)

上一篇我们看到了关系世界和对象世界的不同,正如你看到的,应用程序使用对象模型处理数据库数据很复杂。下一个问题是谁来处理这一复杂性。答案是如果你很疯狂的话,你可以自己解决。否则你可以采用O/RM工具,更确切地说使用Entity Framework。

Entity Framework 4 in Action读书笔记——第一章:数据访问重载:Entity Framework(2)

上一篇讲解了通用数据容器,这一篇使用类来组织数据。
类是面向对象编程语言的基础。使用类,你不需要知道具体的存储机制,数据源可以是数据库,Web服务,XML文件等。类提供了很多优势,尤其是在企业应用中。

Entity Framework 4 in Action读书笔记——第一章:数据访问重载:Entity Framework(1)

写在之前的话
在深入研究实体框架的细节之前,我们先讨论从传统的DataSet方法转换到基于对象的方法实现数据访问所带来的便利,以及这两种方法不同的工作方式是怎样导致采用像Entity Framework这样的O/RM工具。

Entity Framework 4 in Action 读书笔记——开篇

写在开篇之前
Entity Framework 4 In Action 这本书目前还没有中文版的,大体看了一下目录感觉还不错,如果想从中学到东西还是看原汁原味的好。从淘宝上搜了一下这本书要将近100块钱,亚马逊300多,只好将就着看电子书吧,如果想要电子书的朋友,可以到网上搜,有很多资源,这里就不附上下载地址了。
本书内容一览
Entity Framework 4 In Action 这本书适合于所有的Entity Framework开发者阅读,不管你是开发小型应用程序还是大型企业系统,你都会从这本书中受益颇多。本书将带领你从零开始创建一个应用程序,逐步向你展示Entity Framework的各种特性。
本书分为4部分,共19章。
1部分
介绍O/RM模式的基础知识以及创建基础应用程序时的实体框架的基本原则。
2部分
详细讨论实体框架主要的构成:映射(mapping),查询( querying)和持久性(persistence)
3部分
展示如何利用实体框架的高级特性。
4部分
展示如何在不同类型的应用程序:WindowsWebWeb Service中更好地使用实体框架。



 .NET 4.0 - ADO.NET Entity Framework 4.0 新特性

介绍
ADO.NET Entity Framework 4.0 的新增功能
  • 对外键的支持,即把外键当做实体的一个属性来处理 
  • 对复杂类型的支持,即实体属性可以是一个复杂类型 
  • 将多个表映射到一个概念实体,将一个表拆为多个概念实体 
  • 增强了 LINQ to Entities
  • 新增了对 POCO(Plain Old CLR Object)的支持,即 Model 代码中不会有任何关于持久化的代码 
  • 其他新特性

Entity Framework加载相关实体——Lazy Loading,Eager Loading,Explicit Loading

Entity Framework提供了三种加载相关实体的方法:Lazy Loading,Eager Loading和Explicit Loading。首先我们先来看一下MSDN对三种加载实体方法的定义。

Oracle Data Provider for .NET Distinctive Database Development

TECHNOLOGY: Oracle Data Provider for .NET

As Published In 
Oracle Magazine 
September/October 2011
  

Distinctive Database Development

By Christian Shay

Use Entity Framework with Oracle Data Provider for .NET.
Object-relational mapping (ORM) technologies enable developers to write object-oriented code against a conceptual model of their data rather than accessing the database directly. For example, with an ORM, a developer can make an update to an instance of an EMPLOYEE class or request a collection of EMPLOYEE instances rather than executing the equivalent UPDATE or SELECT SQL statements against the EMPLOYEES table in an Oracle database.

LINQ to Entities简介


一键收藏,随时查看,分享好友!
《LINQ实战》第8章LINQ to SQL高级特性,本章将要继续介绍LINQ to SQL的高级特性。首先将从扩展前一章中业务实体的生命周期开始,主要关注并发性和事务性相关的问题。本节为LINQ to Entities简介。

将 Entity Framework、LINQ 和 Model-First 用于 Oracle 数据库

将 Entity Framework、LINQ 和 Model-First 用于 Oracle 数据库

目的

本教程介绍如何使用 Entity Framework、语言集成查询 (LINQ),以及如何对 Oracle 数据库使用 Model-First 以生成数据定义语言 (DDL) 脚本。

【译著】Code First :使用Entity. Framework编程(8)

Chapter 8

What’s Coming Next for Code First

第8章

Code First将走向哪里?

So far, this book has covered all of the Code First components that reached their final release at the time of writing. There are, however, some notable features that are still in preview at this time that you should be aware of. You’ll gain the ability to migrate a database schema as your Code First model evolves, reverse engineer a Code First model from an existing database, and many other useful tasks.

【译著】Code First :使用Entity. Framework编程(7)

Chapter7

Advanced Concepts

第7章

高级概念

The Code First modeling functionality that you have seen so far should be enough to get you up and running with most applications. However, Code First also includes some more advanced functionality that you may require as your needs advance. Throughout this book you’ve seen Code First’s conventions in action, but if there are one or more conventions you don’t like, Code First allows you to remove them. You may also want to get rid of that EdmMetadata table Code First is adding to your database. Code First caches its model by default, and it’s possible to override that behavior to solve problems like targeting multiple database providers in the same application in stance. This chapter will cover these topics and more.

【译著】Code First :使用Entity. Framework编程(6)

Chapter6

Controlling Database Location,Creation Process, and Seed Data

第6章

控制数据库位置,创建过程和种子数据

In previous chapters you have seen how convention and configuration can be used to affect the model and the resulting database schema. In this chapter you will see how the convention and configuration concept applies to the database that is used by Code First.
You’ll learn how Code First conventions select a database and how you can alter this convention or specify the exact database that your context should use. The topics we cover will help you target other database providers, deploy your application, and perform many other database-related tasks.