• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DataModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DataModel的典型用法代码示例。如果您正苦于以下问题:C# DataModel类的具体用法?C# DataModel怎么用?C# DataModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataModel类属于命名空间,在下文中一共展示了DataModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GeneratePeopleAndCompute

    public void GeneratePeopleAndCompute()
    {
        int numberOfPeople = 0;
        try { numberOfPeople = int.Parse(NumberOfPeopleField.text); } catch { NumberOfPeopleField.text = numberOfPeople.ToString(); }
        int startingYear = 1900;
        try { startingYear = int.Parse(StartingYearField.text); } catch { StartingYearField.text = startingYear.ToString(); }
        int endingYear = 2000;
        try { endingYear = int.Parse(EndingYearField.text); } catch { EndingYearField.text = endingYear.ToString(); }
        int maxLifespan = 100;
        try { maxLifespan = int.Parse(MaxLifespanField.text); } catch { MaxLifespanField.text = maxLifespan.ToString(); }

        if (startingYear > endingYear )
        {
            int temp = startingYear;
            startingYear = endingYear;
            endingYear = temp;
            StartingYearField.text = startingYear.ToString();
            EndingYearField.text = endingYear.ToString();
        }

        DataModel model = new DataModel(numberOfPeople, startingYear, endingYear, maxLifespan);

        PeopleView.PopulatePeopleView(model.People);

        int[] mappingOfPopulationToDate = DateComputation.ComputeNumberOfLivingForEachYear(model.People, startingYear, endingYear);
        Graph.PopulateGraph(startingYear, endingYear, numberOfPeople, mappingOfPopulationToDate);

        int mostPopulousYear = DateComputation.ComputeDateOfMostLiving(mappingOfPopulationToDate, startingYear);
        MostPopulousYearField.text = mostPopulousYear.ToString();
        PopulationField.text = mappingOfPopulationToDate[mostPopulousYear - startingYear].ToString();
    }
开发者ID:crsteinb,项目名称:ComputePopulation,代码行数:31,代码来源:GUIController.cs


示例2: Index

 public ActionResult Index()
 {
     var dataModel = new DataModel {HiveQl = "SELECT * FROM sample_08 LIMIT 100;"};
     var dt = new DataTable();
     dataModel.Dt = dt;
     return View(dataModel);
 }
开发者ID:mrcouthy,项目名称:Asp.netHortonHive,代码行数:7,代码来源:SampleDataController.cs


示例3: TranslateBlock

 /// <summary>
 /// Driver to find the proper translator for a particular object type
 /// </summary>
 /// <param name="iCalObjectName"></param>
 /// <param name="rawModel"></param>
 /// <returns></returns>
 private static IEnumerable<object> TranslateBlock(string iCalObjectName, DataModel.RawModel[] rawModel)
 {
     if (!_translators.ContainsKey(iCalObjectName))
         return null;
     var translator = _translators[iCalObjectName];
     return rawModel.Select(rm => translator(rm));
 }
开发者ID:j0inty,项目名称:iCal.PCL,代码行数:13,代码来源:iCalSerializer.cs


示例4: Person

 public Person(DataModel.Person data) {
   Data = data;
   Id = data.Id;
   Title = data.Name;
   IconName = "appbar_people";
   PeopleGroupId = data.PeopleGroupId;
 }
开发者ID:martin-holy,项目名称:PictureManager,代码行数:7,代码来源:Person.cs


示例5: notifyCompletedLearners

        private void notifyCompletedLearners(DataModel context, ILog log)
        {
            var learnersByDivision = Enrollment.CompletedToday(context)
                .Include(e => e.Learner)
                .Select(e => e.Learner)
                .Include(l => l.Division).ToList()
                .GroupBy(l => l.Division);

            foreach (var grouping in learnersByDivision)
            {
                var division = grouping.Key;

                var mail = new MailMessage("[email protected]", division.Email);
                var builder = new StringBuilder();
                builder.AppendLine("The following learners have completed their enrollments today:");
                foreach (var learner in grouping)
                {
                    log.Info($"Notified {learner.DivisionAbreviation} that learner {learner.LearnerNumber} completed their enrollment.");
                    builder.AppendLine($"{learner.DivisionAbreviation}{learner.LearnerNumber}\t{learner.Surname}, {learner.Name}");
                }
                mail.Subject = "Learners that have completed their enrollments";
                mail.Body = builder.ToString();

                var outbox = new Outbox();
                outbox.Send(mail);
            }
        }
开发者ID:robertfall,项目名称:LAD,代码行数:27,代码来源:NotifyCompletedLearners.cs


示例6: InsertTodoItem

        private async Task InsertTodoItem(DataModel.TodoItem todoItem)
        {
            string errorString = string.Empty;

            if (media != null)
            {
                todoItem.ContainerName = "todoitemimages";
                todoItem.ResourceName = Guid.NewGuid().ToString();
            }

            await todoTable.InsertAsync(todoItem);

            if (!string.IsNullOrEmpty(todoItem.SasQueryString))
            {
                StorageCredentials cred = new StorageCredentials(todoItem.SasQueryString);
                var imageUri = new Uri(todoItem.ImageUri);

                CloudBlobContainer container = new CloudBlobContainer(
                    new Uri(string.Format("https://{0}/{1}",
                        imageUri.Host, todoItem.ContainerName)), cred);

                using (var inputStream = await media.OpenReadAsync())
                {
                    CloudBlockBlob blobFromSASCredential =
                        container.GetBlockBlobReference(todoItem.ResourceName);
                    await blobFromSASCredential.UploadFromStreamAsync(inputStream);
                }
                
                await ResetCaptureAsync();
            }

            items.Add(todoItem);
        }
开发者ID:cealmees,项目名称:Appdoptame,代码行数:33,代码来源:MainPage.xaml.cs


示例7: Execute

        public override void Execute(DataModel context, ILog log)
        {
            var scannedLearners = context.ScannedInLearners.ToList().Where(s => DateTime.Now - s.TimeIn > TimeSpan.FromHours(5));
            var scans = scannedLearners.Select(scannedLearner =>
               new LearnerScan()
               {
                   CreatedAt = DateTime.Now,
                   Activity = "Scanned Out",
                   Details = "Out (Automatic Midnight)",
                   ScanType = "Attendance",
                   Division = scannedLearner.Division,
                   LearnerNumber = scannedLearner.LearnerNumber,
                   Username = "System",
                   Session = scannedLearner.Session,
                   PartnerID = scannedLearner.LinkID
               }
            ).ToList();

            context.LearnerScans.AddRange(scans);
            context.SaveChanges();

            foreach (var scan in scans)
            {
                log.Info($"Scanning out learner: {scan.LearnerNumber} from {scan.Division}");
                if (scan.PartnerID == null) continue;
                var partner = context.LearnerScans.FirstOrDefault(s => s.ID == scan.PartnerID);
                if (partner != null)
                {
                    partner.PartnerID = scan.ID;
                }
            }
            context.ScannedInLearners.RemoveRange(scannedLearners);

            context.SaveChanges();
        }
开发者ID:robertfall,项目名称:LAD,代码行数:35,代码来源:ScanOutLearners.cs


示例8: CreateEvent

        public int CreateEvent(string currentUsername, DataModel.Event baseEvent)
        {
            var usBusiness = new Business.Users(base.db);
            CityAngels.DataModel.User loggedUser = usBusiness.GetUser(currentUsername);

            // create event
            if (baseEvent.DateTo == DateTime.MinValue) baseEvent.DateTo = null;

            // standart schedule type (weekly)
            if (baseEvent.IsPeriodic)
            {
                baseEvent.EventSchedulingTypeId = (int)Data.Enum.ScheduleType.WEEKLY;
            }

            // baseEvent.RefEventId = null; <- non rimuovo il riferimento all'evento ripetuto, mi serve per non ripetere due volte l'evento nella giornata
            baseEvent.IsEnabled = true;
            baseEvent.CreateDate = DateTime.Now;
            baseEvent.CreatorUserId = loggedUser.UserId;
            baseEvent.UpdateDate = DateTime.Now;
            baseEvent.UpdateUserId = loggedUser.UserId;

            db.Events.Add(baseEvent);

            // log for other users
            Business.Logs log = new Business.Logs(base.db, Data.Enum.LogTypes.NEW, loggedUser);
            log.Push(baseEvent);

            db.SaveChanges();

            return baseEvent.EventId;
        }
开发者ID:gio-js,项目名称:CityAngels,代码行数:31,代码来源:Events.cs


示例9: PopulateDataModel

        public void PopulateDataModel(DataModel model)
        {
            Instruction[] dynamicMethodCalls = ExtractDynamicMethodCallInstructions();
            if (dynamicMethodCalls.Length == 0) { return; }

            Instruction[] cachedReflectedFields = ExtractInitialReflectedCachedFieldReferenceInstructions();
            if (cachedReflectedFields.Length == 0) { return; }

            var references = cachedReflectedFields
                .Select(field => field.ParseToFieldReferenceCreation())
                .Reverse<string>()
                .ToList<string>();

            if (references.Count != 2) { return; }

            string tableName = references[0];
            string columnName = references[1].Replace("FindBy", "");
            Type columnType = null;

            var actualCall = dynamicMethodCalls.Last();

            var current = actualCall.Previous;
            if(current.OpCode.Code == Code.Ldstr)
            {
                columnType = typeof (string);
            } 
            else if (current.OpCode.Code == Code.Ldc_I4_4) // etc
            {
                columnType = typeof(int);
            }

            model.Table(tableName)
                .Column(columnName)
                .SetType(columnType);
        }
开发者ID:robashton,项目名称:Simple.Data.Generation,代码行数:35,代码来源:MethodInspector.cs


示例10: ReturnAPage

 public ActionResult ReturnAPage(string hiveQl)
 {
     var dataModel = new DataModel {HiveQl = hiveQl};
     DataTable dt = new HiveQueryDataService().GetDataFromHivet(dataModel.HiveQl);
     dataModel.Dt = dt;
     return View("Index", dataModel);
 }
开发者ID:mrcouthy,项目名称:Asp.netHortonHive,代码行数:7,代码来源:SampleDataController.cs


示例11: NewsGoVnGroup_Parse

        public static async Task<DataGroup> NewsGoVnGroup_Parse(string xmlString, DataModel.DataGroup group, int takeNum)
        {
            StringReader _stringReader = new StringReader(xmlString);
            XDocument _xdoc = XDocument.Load(_stringReader);
            var channelElement = _xdoc.Element("rss").Element("channel");
            if (channelElement != null)
            {
                group.Title = channelElement.Element("title").Value;
                group.Subtitle = channelElement.Element("title").Value;
                group.Description = channelElement.Element("description").Value;

                var items = channelElement.Elements("item");
                foreach (var item in items)
                {
                    if (group.Items.Count == takeNum && takeNum >= 0) break;

                    DataItem dataItem = new DataItem();
                    dataItem.Title = item.Element("title").Value;
                    dataItem.Description = StripHTML(item.Element("description").Value);
                    dataItem.Link = new Uri(item.Element("link").Value, UriKind.Absolute);
                    dataItem.PubDate = item.Element("pubDate").Value;

                    HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
                    htmlDoc.Load(new StringReader(item.Element("description").Value));

                    HtmlAgilityPack.HtmlNode imageLink = getFirstNode("img", htmlDoc.DocumentNode);
                    dataItem.ImageUri = new Uri(imageLink.GetAttributeValue("src", string.Empty).Replace("96.62.jpg", "240.155.jpg"), UriKind.Absolute);

                    dataItem.Group = group;
                    group.Items.Add(dataItem);
                }
            }

            return group;
        }
开发者ID:nhannguyen2204,项目名称:VnFeeds_Win8,代码行数:35,代码来源:ParseDocHelper.cs


示例12: SaveConfig

 public void SaveConfig(DataModel.xTraceConfig xConfig)
 {
     localSettings.Values["ISFIRSTRUN"] = xConfig.ISFIRSTRUN;
     localSettings.Values["IPADDR"] = xConfig.IPADDR;
     localSettings.Values["PORT"] = xConfig.PORT;
     CurrentSettings = xConfig;
 }
开发者ID:lotusharley,项目名称:xTrace,代码行数:7,代码来源:ConfigUtils.cs


示例13: ToBeCompleted

 public static IQueryable<Enrollment> ToBeCompleted(DataModel context)
 {
     var enrollmentIDs = context.Database.SqlQuery<long>(@"
         SELECT e.idEnrollments
         FROM enrollments e
         JOIN learner_details l ON l.learnerKey = e.learnerKey
         WHERE e.completed IS NULL
         AND (
           SELECT COUNT(*)
           FROM learnerEnrollmentComponents lecom
           WHERE lecom.idEnrollments = e.idEnrollments
           AND lecom.moderated = 'yes'
         ) > 0
         AND 'Competent' = ALL (
           SELECT outcome
           FROM learnerEnrollmentComponents lecom
           WHERE lecom.idEnrollments = e.idEnrollments
         )
         AND 'yes' = ALL (
           SELECT moderated
           FROM learnerEnrollmentComponents lecom
           WHERE lecom.idEnrollments = e.idEnrollments
         );
     ").ToList();
     return context.Enrollments.Where(e => enrollmentIDs.Contains(e.ID));
 }
开发者ID:robertfall,项目名称:LAD,代码行数:26,代码来源:Enrollment.cs


示例14: AddUser

        public UserEntity AddUser(DataModel.UserEntity user)
        {
            var userToUpdate = new User();
            userToUpdate.FirstName = user.FirstName;
            userToUpdate.LastName = user.LastName;
            userToUpdate.Email = user.Email;
            userToUpdate.PositionId = user.PositionId;
            userToUpdate.UserName = user.UserName;
            userToUpdate.Password = user.Password;

            if (user.Projects.Count > 0)
            {
                foreach (var item in user.Projects)
                {
                    Project p = dataContext.Projects.Where(q => q.ProjectId == item.ProjectId).First();
                    userToUpdate.Projects.Add(p);
                }
            }

            if (user.Rights.Count > 0)
            {
                foreach (var item in user.Rights)
                {
                    Right r = dataContext.Rights.First(c => c.RightId == item.RightId);
                    userToUpdate.Rights.Add(r);
                }
            }

            dataContext.Users.Add(userToUpdate);
            dataContext.SaveChanges();

            return user;
        }
开发者ID:noopydoopy,项目名称:GBSPM_WEBPROJECT,代码行数:33,代码来源:UserRepository.cs


示例15: PlaylistItem

        public PlaylistItem(MPDSongResponseBlock block, DataModel dataModel)
        {
            Path = new Path(block.File);
            Position = block.Pos;
            Id = block.Id;

            if (Path.IsStream())
            {
                Artist = null;
                Album = null;
                AudioStream stream = dataModel.StreamsCollection.StreamByPath(Path);

                if (stream != null)
                {
                    Title = stream.Label;
                }
                else
                {
                    Title = block.Name ?? Path.ToString();
                }
            }
            else
            {
                Title = block.Title;
                Album = block.Album;

                if (Settings.Default.UseAlbumArtist)
                {
                    Artist = block.AlbumArtist ?? block.Artist;
                }

                Artist = block.Artist;
            }
        }
开发者ID:paukr,项目名称:auremo,代码行数:34,代码来源:PlaylistItem.cs


示例16: ForEach

        /// <summary>
        ///     遍历列
        /// </summary>
        /// <param name="cols">列集合</param>
        /// <param name="format">模板</param>
        /// <returns></returns>
        public string ForEach(ColumnSchemaCollection cols, string format)
        {
            var sb = new StringBuilder();
            foreach (ColumnSchema col in cols)
            {
                bool isPrimaryKeyMember = col.IsPrimaryKeyMember; // 是否为主键列
                var m = new DataModel
                {
                    TableName = base.TableName,
                    TableComment = DbUtil.GetComment(base.Table.Description, base.TableName),
                    ColumnName = DbUtil.GetColumnName(col.Name, this.CutColumnName),
                    ColumnDbType = col.NativeType,
                    ColumnType = DbUtil.GetColumnType(col.SystemType),
                    ColumnLength = (col.Size < 0 ? int.MaxValue : col.Size).ToString(),
                    ColumnEnableNull = col.AllowDBNull,
                    ColumnIdentity = Convert.ToBoolean(col.ExtendedProperties["CS_IsIdentity"].Value.ToString())
                };

                m.ColumnComment = DbUtil.GetComment(col.Description, m.ColumnName);
                m.ColumnComment = isPrimaryKeyMember ? m.ColumnComment + " 主键" : m.ColumnComment;

                m.ColumnType = m.ColumnEnableNull ? m.ColumnType + "?" : m.ColumnType;

                sb.AppendLine(DbUtil.Format(format, m));
            }
            return sb.ToString();
        }
开发者ID:raee,项目名称:CodeSmith-Template,代码行数:33,代码来源:BaseTemplate.cs


示例17: Execute

        public override void Execute(DataModel context, ILog log)
        {
            var today = DateTime.Today;
            var scannedEmployees = context.ScannedInEmployees
                .Include(e => e.InScan)
                .Where(s => DbFunctions.TruncateTime(s.InScan.CreatedAt) < today)
                .ToList();
            foreach (var scannedEmployee in scannedEmployees)
            {
                var scanIn = context.EmployeeScans.Find(scannedEmployee.ScanID);
                var scan = new EmployeeScan()
                {
                    CreatedAt = scanIn.CreatedAt,
                    EmployeeNumber = scannedEmployee.EmployeeNumber,
                    Division = scanIn.Division,
                    Details = "Out (System)",
                    ScanType = "Type",
                    PartnerID = scanIn.ID,
                    Username = "System"
                };

                log.Info($"Scanning out Employee: {scan.EmployeeNumber} from {scan.Division}");
                context.EmployeeScans.Add(scan);
            }
            context.ScannedInEmployees.RemoveRange(scannedEmployees);
            context.SaveChanges();
        }
开发者ID:robertfall,项目名称:LAD,代码行数:27,代码来源:ScanOutEmployees.cs


示例18: LoadDataFromJson

    private void LoadDataFromJson(string json)
    {
        JSONNode rootNode = JSON.Parse(json);
        for (int i = 0; i < rootNode.Count; i++) {
            DataModel dm = new DataModel();
            dm.Name = rootNode[i]["name"];
            for (int j = 0; j < rootNode[i][0].Count; j++) {
                switch (j) {
                case 0:
                    dm.VolumeArmazenado = rootNode[i][0][j].AsFloat;
                break;
                case 1:
                    dm.PluviometriaDoDia = rootNode[i][0][j].AsFloat;
                    break;
                case 2:
                    dm.PluviometriaAcuMes = rootNode[i][0][j].AsFloat;
                    break;
                case 3:
                    dm.MediHistMes = rootNode[i][0][j].AsFloat;
                    break;
                }
            }
            AppDataManager.instance.dataModels.Add(dm);
        }

        StartCoroutine(LoadLevel());
    }
开发者ID:CristianKhalilSC,项目名称:CITHackaton-MonitoramentoRepresas,代码行数:27,代码来源:LoadController.cs


示例19: ToContract

 /// <summary>
 /// Converts object of class <see cref="DataModel.FileInfo"/> into its 
 /// data transfer representation <see cref="FileInfo"/>.
 /// </summary>
 /// <param name="info">
 /// An object to convert.
 /// </param>
 /// <returns>
 /// An instance of <see cref="FileInfo"/> that corresponds value of <paramref name="info"/>
 /// </returns>
 public FileInfo ToContract(DataModel.FileInfo info)
 {
     return new FileInfo
                {
                    Id = info.Id,
                    Name = info.Name
                };
 }
开发者ID:kapitanov,项目名称:diploma,代码行数:18,代码来源:FileClassesConverter.cs


示例20: Viewer

    public Viewer(DataModel.Viewer data) : this() {
      Data = data;
      Id = data.Id;
      Title = data.Name;

      LoadFolders(true);
      LoadFolders(false);
    }
开发者ID:martin-holy,项目名称:PictureManager,代码行数:8,代码来源:Viewer.cs



注:本文中的DataModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DataNew类代码示例发布时间:2022-05-24
下一篇:
C# DataManager类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap