_Samples/Example_ActiveRecord.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data;
using System.Data.Common;

//<doc:using>
using ComLib;
using ComLib.Entities;
using ComLib.Extensions;
//</doc:using>
using ComLib.Application;


namespace ComLib.Samples
{
    /// <summary>
    /// Example of ActiveRecord Initialization/Configuration.
    /// </summary>
    public class Example_ActiveRecord : App
    {
        private string _creationType = "factory_repo_only";

		//<doc:example>
        /// <summary>
        /// ActiveRecord type 2:
        /// Combined entity and active record functionality.
        /// </summary>
        private class Person : ActiveRecordBaseEntity<Person>
        {
            public string Name { get; set; }
            public string About { get; set; }
            public int Age { get; set; }
            public bool IsManager { get; set; }
            public DateTime StartDate { get; set; }
            public string Email { get; set; }
            public string Phone { get; set; }
            public string Url { get; set; }
        }


        /// <summary>
        /// Run the application.
        /// </summary>
        public override BoolMessageItem Execute()
        {
            int lastId = 0;
			int sampleCount = 10;
			
            // 1. Create.
            sampleCount.Times( ndx =>
            {
                var newPerson = new Person()
                {
                    Name = "John", Age = ndx, Email = "john" + ndx + "@y.com",
                    IsManager = ndx % 2 == 0, StartDate = DateTime.Today.AddDays(-1 * ndx),
                    Phone = "111-111-111" + ndx, Url = "http://john" + ndx + ".com"
                };
后面还有 69 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。