示例#1
0
        public bool Bind()
        {
            if (response.RowSets.Length == 0)
            {
                return(false);
            }

            RowSet rowSet = response.RowSets[0];

            string idPropertyName = ModelIdentifier.GetPropertyName <TModel>();

            foreach (Row row in rowSet.Rows)
            {
                TModel model = new TModel();

                modelProperties.TrySetValueFromString(model, idPropertyName, row.id);

                foreach (XmlElement cell in row.Any)
                {
                    string field = XmlConvert.DecodeName(cell.Name);

                    modelProperties.TrySetValueFromString(model, field, cell.InnerText);
                }
                records.Add(model);
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// Updates the model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="name">The name.</param>
        /// <param name="value">The value.</param>
        /// <param name="useDisplayName">if set to <c>true</c> [use display name].</param>
        public void UpdateModel(TModel model, string name, string value, bool useDisplayName)
        {
            ViewField field = useDisplayName ? viewFieldsCollection.FindByDisplayName(name) : viewFieldsCollection.FindByName(name);

            if (field != null)
            {
                modelProperties.TrySetValueFromString(model, field.DisplayName, value);
            }
        }
        public bool Bind()
        {
            if (string.IsNullOrEmpty(idProperty))
            {
                return(false);
            }

            if (models.Count == dataSubmissionResults.Length)
            {
                for (int i = 0; i < dataSubmissionResults.Length; i++)
                {
                    TModel model = models[i];
                    DataSubmissionResult result = dataSubmissionResults[i];

                    if (result.RecordAction == RecordAction.Insert)
                    {
                        modelProperties.TrySetValueFromString(model, idProperty, Convert.ToString(result.SetId));
                    }
                }
            }
            return(true);
        }