当前位置: 首页>>代码示例>>C#>>正文


C# DataModel类代码示例

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


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


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