In Entity Framework 4.0, Poco (simple traditional CLR object/plain old CLR object) is supported, so that we can focus on business logic and perform unit tests more effectively. poco does not need to inherit from the default EF entity, so it can be switched more flexibly.
This article describes how to automatically generate poco and replace the entity generated by EF to separate the two.
Download and install the POCO entity generator
This document uses the T4
T4: Use a tree array to find reverse order PairsA [I] is the prefix andDerivation (A [J]-A [I])/(J-I)> = mA [J]-A [I]> = m (J-I)A [J]-M * j> = A [I]-M * IB [J]> = B [I]This is the reverse order.Next, let's learn how to use a tree array.The principle is: the tree array is used to calculate the Range Sum, right?That is, statistics by weight range can be maintained by bit...Scan it againThat is, how many Reverse Order pairs are computedThe interval stati
Visual Studio 2013 EF5 Object Data Model edmx uses the inherited object dbcontext generated by the T4 template. The familiar objectcontext object is missing. Of course, not every programmer needs the objectcontext object, there are two solutions:
Method 1. open model. Context. CS and add
Public oraclemodelentities (objectcontext, bool dbcontextownsobjectcontext): Base (objectcontext, dbcontextownsobjectcontext){}
As follows:
using System; using
Label:There is a workaround on the internet as follows: Http://www.cnblogs.com/stone_w/archive/2012/10/25/2738345.html But I tried. It's too much trouble, and once the EF is rebuilt and rebuilt. Later I queried the information, can use the T4 template to solve this problem. 1. Download file getsummery.ttinclude, here I have provided, everyone to download: download 2. Unzip the files we downloaded and put the extracted files into the solution3. Modify
Tags: substring programming spec red Dapper MYSQ threading index usingThere have been two previous,EF select MySQL data source with EF Add the ADO entity model directly select Oracle Data source , its convenience is not much to say, use Dbfirst direct dot point can be updated with the database two-way, And the key is to facilitate our use of T4, such as: (If you have a general understanding of T4, you will
defined the recursive type.So, just construct the matrix a ={1 1 5 31 0 0 00 0 1 10 0 1 0}Among them, the transverse four numbers are respectively represented Ans[i-1],ans[i-2], f[i-1], f[i-2]Portrait four numbers respectively Ans[i],ans[i-1], F[i], f[i-1]Then we use the N-2 power of this matrix to multiply the vector b ={5021}These four numbers represent ans[2],ans[1], f[2], f[1].After multiplying to get a matrix of 4 * 1, the answer is the number in the first column of the first row.When calc
The database used in this example is Northwind1. New TT text template customer.tt2. Modify the Customer.tt content to"false"Hostspecific="false"Language="C #"#>". CS"#>"System.Core.dll"#>"System.Data.dll"#>"System.Data.DataSetExtensions.dll"#>"System.Xml.dll"#>namespace="System"#>namespace="System.Xml"#>namespace="System.Linq"#>namespace="System.Data"#>namespace="System.Data.SqlClient"#>namespace="System.Collections.Generic"#>namespace="System.IO"#>"$ (ProjectDir) Dbhelper.ttinclude"#>//--------
When the EF Power Tools database is reverse generated, the T4 template is modified, and the eft4
On VS2013, the Reverse Engineer Code First of EF Power Tools is used for Reverse generation.
It is found that the decimal (18, 4) field in the database has no precision or decimal places in the generated mapping class.
This enables the automatically generated SQL statement to use decimal (18, 2) by default when saving data through EF ).
Fortunately, EF Pow
])
{
He = J + K + G;
If (ANS [Z] =-1)
{
If (! F [He % N])
{
Ans [Z] = He % N;
Ans [x] = J;
Ans [y] = K;
F [J] = true;
F [k] = true;
F [He % N] = true;
If (! Judge (I ))
Work (I + 1, he/N );
If (FF) return;
Ans [Z] =-1;
Ans [x] =-1;
Ans [y] =-1;
F [He % N] = false;
F [J] = false;
F [k] = false;
}
}
Else
{
If (he % N = ans [Z])
{
Ans [x] = J;
Ans [y] = K;
F [J] = true;
F [k] = true;
If (! Judge (I ))
Work (I + 1, he/N );
If (FF) return;
Ans [x] =-1;
Ans [y] =-1;
F [J] = false;
F [k] = false;
}
}
}
first, the definition of T4 template and the generation of code files
Let's take a look at what the final code generation needs to define, and how the T4 template should be defined. For this framework, the generation of code structures is implemented by inheriting custom types from our custom base class template. As a demo, we define a demotemplate as follows. As you can see from the code, Demotemplate is
Microsoft Visual Studio contains a code generation engine called the T4 (abbreviation for the text Template Conversion Toolkit). You may have used the T4 template in Visual Studio, and you don't even know that the templates are already working in the background. In this article, I'll briefly introduce the T4 template and explain how ASP.net MVC uses this technolo
Creating an entity is as simple as building a DLL in a T4 file and folder.Using the T4 template Tutorial Step 1Create a T4 template if you can't get it in my demo.Step 2Sets the order set required for the current T4 and references SqlSugar.dllWriting Connection Database codeCall Sqlsugar to generate the entity function
The use of T4 template, can be very convenient from the database map into model models, equivalent to the effect of dynamic and soft. But the soft is can directly generate three layers, abstract factory, T4 not so bull, so we generally only used to generate Modle or server and other specified methods.
Talk less, cut to the chase:
I'll explain in two parts, part of which is to build the method attributes int
How to make TT T4 template output multiple files (VS2010)-access911.net article
Problem:
The TT template feature in VS2010 is very useful, but how to define its output directory, or how to program a TT file to output multiple result files.
Reply:
This class is primarily used to redefine the output position of the TT
, according to the operation of the core business to respond. 4. Common (public Facilities level) 4.1, Rdf.common: This class library mainly for the entire project to provide public operation method, and log log record, here I use Nlog, provides the log interceptor features, as long as the label can record the method may occur the exception, equivalent to the previous exception capture and processing, The processing here only needs to be labeled enter a message that may throw an except
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.