本文整理汇总了C#中IDataSource.GetView方法的典型用法代码示例。如果您正苦于以下问题:C# IDataSource.GetView方法的具体用法?C# IDataSource.GetView怎么用?C# IDataSource.GetView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataSource
的用法示例。
在下文中一共展示了IDataSource.GetView方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeInsertes
private void MakeInsertes(IDataSource ds, JArray data)
{
string id = this.ModelInstance.GetIDProperty();
foreach (JToken token in data)
{
this.record = token;
var jObject = (JObject)token;
values = new SortedList(this.ModelInstance.Fields.Count);
keys = new SortedList();
oldValues = new SortedList();
foreach (ModelField field in this.ModelInstance.Fields)
{
var jProperty = jObject.Property(field.Mapping.IsNotEmpty() ? field.Mapping : field.Name) ?? jObject.Property(field.Name);
values[field.Name] = jProperty != null && jProperty.Value.Type != JTokenType.Null && jProperty.Value.Type != JTokenType.Undefined ? (jProperty.Value.Type == JTokenType.String ? (string)jProperty.Value : this.ChopQuotes(jProperty.Value.ToString(Newtonsoft.Json.Formatting.None))) : null;
}
BeforeRecordInsertedEventArgs eBeforeRecordInserted = new BeforeRecordInsertedEventArgs(record, keys, values);
this.OnBeforeRecordInserted(eBeforeRecordInserted);
if (eBeforeRecordInserted.CancelAll)
{
break;
}
if (eBeforeRecordInserted.Cancel)
{
continue;
}
if (ds != null)
{
ds.GetView("").Insert(values, InsertCallback);
}
else
{
this.InsertCallback(0, null);
}
}
}
示例2: MakeDeletes
private void MakeDeletes(IDataSource ds, JArray data)
{
string id = this.ModelInstance.GetIDProperty();
foreach (JToken token in data)
{
this.record = token;
values = new SortedList(0);
keys = new SortedList();
oldValues = new SortedList(0);
if (id.IsNotEmpty())
{
string idStr = token.Value<string>(id);
int idInt;
if (int.TryParse(idStr, out idInt))
{
keys[id] = idInt;
}
else
{
keys[id] = idStr;
}
}
BeforeRecordDeletedEventArgs eBeforeRecordDeleted = new BeforeRecordDeletedEventArgs(record, keys);
this.OnBeforeRecordDeleted(eBeforeRecordDeleted);
if (eBeforeRecordDeleted.CancelAll)
{
break;
}
if (eBeforeRecordDeleted.Cancel)
{
continue;
}
if (ds != null)
{
ds.GetView("").Delete(keys, oldValues, DeleteCallback);
}
else
{
this.DeleteCallback(0, null);
}
}
}
示例3: ConnectToDataSource
void ConnectToDataSource ()
{
/* verify that the data source exists and is an IDataSource */
object ctrl = null;
if (Parent != null)
ctrl = Parent.FindControl (DataSourceID);
if (ctrl == null || !(ctrl is IDataSource)) {
string format;
if (ctrl == null)
format = "DataSourceID of '{0}' must be the ID of a control of type IDataSource. A control with ID '{1}' could not be found.";
else
format = "DataSourceID of '{0}' must be the ID of a control of type IDataSource. '{1}' is not an IDataSource.";
throw new HttpException (String.Format (format, ID, DataSourceID));
}
boundDataSource = (IDataSource)ctrl;
boundDataSource.GetView (String.Empty).DataSourceViewChanged += new EventHandler(OnDataSourceViewChanged);
}
示例4: MakeUpdates
private void MakeUpdates(IDataSource ds, XmlDocument xml)
{
XmlNodeList updatingRecords = xml.SelectNodes("records/Updated/record");
string id = GetIdColumnName();
foreach (XmlNode node in updatingRecords)
{
record = node;
values = new SortedList(this.Reader.Reader.Fields.Count);
keys = new SortedList();
oldValues = new SortedList();
foreach (RecordField field in this.Reader.Reader.Fields)
{
XmlNode keyNode = node.SelectSingleNode(field.Name);
values[field.Name] = keyNode != null ? keyNode.InnerText : null;
}
confirmation = null;
if (id.IsNotEmpty())
{
XmlNode keyNode = node.SelectSingleNode(id);
string idStr = keyNode != null ? keyNode.InnerText : null;
int idInt;
if (int.TryParse(idStr, out idInt))
{
keys[id] = idInt;
}
else
{
keys[id] = idStr;
}
if (this.UseIdConfirmation && keys[id] != null)
{
confirmation = changingEventArgs.ConfirmationList[keys[id].ToString()];
}
}
BeforeRecordUpdatedEventArgs eBeforeRecordUpdated = new BeforeRecordUpdatedEventArgs(record, keys, values, oldValues, confirmation);
this.OnBeforeRecordUpdated(eBeforeRecordUpdated);
if (eBeforeRecordUpdated.CancelAll)
{
break;
}
if (eBeforeRecordUpdated.Cancel)
{
continue;
}
if (ds !=null)
{
ds.GetView("").Update(keys, values, oldValues, this.UpdateCallback);
}
else
{
this.UpdateCallback(0, null);
}
}
}
示例5: MakeInsertes
private void MakeInsertes(IDataSource ds, XmlDocument xml)
{
XmlNodeList insertingRecords = xml.SelectNodes("records/Created/record");
string id = GetIdColumnName();
foreach (XmlNode node in insertingRecords)
{
record = node;
values = new SortedList(this.Reader.Reader.Fields.Count);
keys = new SortedList();
oldValues = new SortedList();
foreach (RecordField field in this.Reader.Reader.Fields)
{
XmlNode keyNode = node.SelectSingleNode(field.Name);
values[field.Name] = keyNode != null ? keyNode.InnerText : null;
}
confirmation = null;
if (id.IsNotEmpty())
{
XmlNode keyNode = node.SelectSingleNode(id);
if (this.UseIdConfirmation && keyNode != null && keyNode.InnerText.IsNotEmpty())
{
confirmation = changingEventArgs.ConfirmationList[keyNode.InnerText];
}
}
BeforeRecordInsertedEventArgs eBeforeRecordInserted = new BeforeRecordInsertedEventArgs(record, keys, values, confirmation);
this.OnBeforeRecordInserted(eBeforeRecordInserted);
if (eBeforeRecordInserted.CancelAll)
{
break;
}
if (eBeforeRecordInserted.Cancel)
{
continue;
}
if (ds != null)
{
ds.GetView("").Insert(values, InsertCallback);
}
else
{
this.InsertCallback(0, null);
}
}
if (insertingRecords.Count > 0)
{
needRetrieve = true;
}
}
示例6: MakeInsertes
private void MakeInsertes(IDataSource ds, JArray data)
{
string id = this.ModelInstance.GetIDProperty();
foreach (JToken token in data)
{
this.record = token;
values = new SortedList(this.ModelInstance.Fields.Count);
keys = new SortedList();
oldValues = new SortedList();
foreach (ModelField field in this.ModelInstance.Fields)
{
values[field.Name] = token.Value<string>(field.Mapping.IsNotEmpty() ? field.Mapping : field.Name) ?? token.Value<string>(field.Name);
}
BeforeRecordInsertedEventArgs eBeforeRecordInserted = new BeforeRecordInsertedEventArgs(record, keys, values);
this.OnBeforeRecordInserted(eBeforeRecordInserted);
if (eBeforeRecordInserted.CancelAll)
{
break;
}
if (eBeforeRecordInserted.Cancel)
{
continue;
}
if (ds != null)
{
ds.GetView("").Insert(values, InsertCallback);
}
else
{
this.InsertCallback(0, null);
}
}
}