Entity Framework learning Accumulation

Source: Internet
Author: User

From: http://www.cnblogs.com/mbailing/archive/2012/07/16/2593368.html

 

Tips for using ef4.1/4.3

(1) Multi-table join query statement:

VaR query = (from m in context. dic_propertyclassdef.include ("dic_propertytypedef ")
. Include ("dic_propertytypedef.dic_propertyvaluedef ")
. Include ("dic_propertytypedef.dic_propertyoptvaluedef ")

This is a multi-table join query statement. You can keep incude. However, it is recommended that you use SQL or stored procedures for complicated services.

(2) The in statement in ef4.1/4.3:

VaR query = Entities. Where (P => IDs. Contains (P. ID ));
IDS is the ID column you passed in this sentence. It can be an array or a wildcard (list <int>)

(3) paging in EF

Query. orderbydescending (r => r. propid). Skip (startrowindex). Take (maximumrows). tolist ();

Startrowindex is the starting index and the number of maximumrows to query. For example, startrowindex = 0 and maximumrows = 10 are 10 records starting from 0.

EF distribution must be used with orderbydescending.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.