The quick development framework CRL3.0 is released with the latest project example CRLShoppingDemo and Google map api demo.
The last time the CRL was used to implement the big data database/table sharding solution was upgraded to 2.4, and later it was upgraded to version 3.0, mainly because of some changes in the structure.
The ORM and business Package are separated, and the instance project DEMO code CRLShoppingDemo is added. The overall project structure is as follows:
3.0 the update content is as follows:
Upgrade to version 3.0, 2. version X no longer updates Model index value type changed to dynamic reduce QueryList method parameter heavy load added BaseProvider added in select query added Equals Extension Method resolution optimized PackageTrans method, remove the exposed transaction control method, remove the SetContext method, use TransactionScope to implement the overall transaction account system, remove the SQL statement, and change it to the object to modify the data initialization during table creation, in the Model to achieve GetInitData modified the cache null judgment Data Access Object dbHelper renamed to the DBExtend2015-10-23 change field alias returned and processed, do not need to pass the ing relationship
Change QueryFromAllCache method name to QueryFromCache to add CRL Demo project
The above updates are reflected in the 3.0 development document.
Update of Main Functions
1. In select creates an equivalent Association in query, and there is also a relative Not In
// Equivalent to product. userId in (select UserId from order where product. supplierId = 10 and order. status = 2) query. in <Code. order> (B => B. userId, B => B. userId, (a, B) =>. supplierId = "10" & B. status = 2 );
2. Equals extension method. Different types of fields and parameters can be used for Equality judgment, eliminating the need for conversion.
Query. Where (B => B. UserId. Equals (Code. ProductChannel. Other); // Equals by value, enum Equals to int
3. The unified transaction calling method PackageTrans does not need to be rolled back manually.
Public bool TransactionTest (out string error) {// simplifies the transaction writing and automatically submits the rollback return PackageTrans (out string ex) =>{ ex = ""; var product = new ProductData (); product. barCode = "sdfsdf"; product. number = 10; ProductDataManage. instance. add (product); // return false; // product = new ProductData (); // product. barCode = "sdfsdf2"; // product. number = 12; ProductDataManage. instance. add (product); // if the data validation rule is not met, an exception will be thrown and an error will be rolled back. // return false; return true ;}, out error );}
4. The initial data is changed to the GetInitData method in the Model. When the object table is created, the data is also created.
/// <Summary> /// Product /// </summary> public class Product: CRL. package. product. productBase {/// <summary> /// initial default data /// </summary> /// <returns> </returns> public override System. collections. IList GetInitData () {var list = new List <Product> (); for (int I = 1; I <100; I ++) {list. add (new Product () {ProductName = "test Product" + I, SettlementPrice = 80, SoldPrice = 100, SupplierId = 1, ProductStatus = CRL. package. product. productStatus. shelved});} return list ;}}
Demonstration Project CRLShoppingDemo
Some people mentioned that they do not understand the document and want to have a simple example. As you wish, they wrote a Demo based on the basic online sales system. The following figure shows the running effect.
This demo project, as mentioned above, implements these services using a simplified method
Inherit business encapsulation for member management
public class MemberManage : CRL.Package.Person.PersonBusiness<MemberManage, Member>
Both merchants and members have login and authentication methods, and Form authentication is implemented.
Public ActionResult Login (Model. Member member) {string error; var a = MemberManage. Instance. CheckPass (member. AccountNo, member. PassWord, out error); if (! A) {ModelState. addModelError ("", error); return View ();} var u = MemberManage. instance. queryItem (B => B. accountNo = member. accountNo); if (u. locked) {ModelState. addModelError ("", "account locked"); return View ();} MemberManage. instance. login (u, "Member", false); string returnUrl = Request ["returnUrl"]; if (string. isNullOrEmpty (returnUrl) {returnUrl = "/";} return Redirect (returnUrl );}
The current user needs to be retrieved on the page, and a unified Person object is returned through Form authentication.
var user = MemberManage.Instance.CurrentUser;//CRL.Package.Person.Person
Similar to FindOne and FindList, the paging method does not need to be silly many times (generally, layer-3 structure will write this method N times) and has been automatically converted
Var item = ProductManage. instance. queryItemFromCache (B => B. id = id); // query var item = ProductManage from the cache. instance. queryItem (B => B. id = id); // search from the database
// Pagination
Var query = ProductManage. Instance. GetLambdaQuery ();
Query. Where (B => B. SupplierId = CurrentUser. Id );
Int count;
Var result = ProductManage. Instance. Page (query, out count );
Built-in Account Transaction System to solve various payment management problems
You can set N currency types for N roles for unified management.
For example
Public bool Charge (Member member, decimal amount, string remark, TransactionType transactionType, out string error) {var account = Transaction. accountManage. instance. getAccountId (member. id, Model. accountType. member, transactionType); string orderId = DateTime. now. toString ("yyMMddhhmmssff"); int tradeType = 10001; var trans = new List <CRL. package. account. transaction> (); var ts = new CRL. package. account. transaction () {AccountId = account, Amount = amount, OperateType = CRL. package. account. operateType. revenue, TradeType = tradeType, OutOrderId = orderId, Remark = remark}; trans. add (ts); bool B = Transaction. transactionManage. instance. submitTransaction (out error, true, trans. toArray (); // submit the stream return B ;}
Fee deduction when confirming order, and points are given at the same time
Var accountUser = Transaction. accountManage. instance. getAccount (order. userId, Model. accountType. member, Model. transactionType. cash); var accountUser2 = Transaction. accountManage. instance. getAccount (order. userId, Model. accountType. member, Model. transactionType. points); if (accountUser. availableBalance <order. totalAmount) {error = "insufficient account balance"; return false;} int tradeType = 1001; var amount = order. totalAmount; va R orderId = order. orderId; var remark = "order payment"; var trans = new List <CRL. package. account. transaction> (); // generate the membership Transaction flow var ts = new CRL. package. account. transaction () {AccountId = accountUser. id, Amount = amount, OperateType = CRL. package. account. operateType. expenditure, TradeType = tradeType, OutOrderId = orderId, Remark = remark}; trans. add (ts); // presents the credit var ts3 = new CRL. package. account. transaction () {Acco UntId = accountUser2.Id, Amount = amount, OperateType = CRL. package. account. operateType. revenue, TradeType = tradeType, OutOrderId = orderId, Remark = "Complimentary points"}; trans. add (ts3); bool B = Transaction. transactionManage. instance. submitTransaction (out error, trans. toArray (); // submit the stream if (! B) {return false ;}
For more details, refer to examples and development documents.
Sample source code(Does not contain CRL source code) http://pan.baidu.com/s/1mg1YDqK
No one pays attention to it. To increase popularity, please join the Group to obtain the complete CRL3.0 source code. Thank you for your support.