本文整理汇总了C#中Newtonsoft.Json.Linq.JObject.GetId方法的典型用法代码示例。如果您正苦于以下问题:C# JObject.GetId方法的具体用法?C# JObject.GetId怎么用?C# JObject.GetId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JObject
的用法示例。
在下文中一共展示了JObject.GetId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateFields
public static void UpdateFields(this JObject to, JObject from)
{
var id = from.GetId();
var key = from.GetKey();
var revision = from.GetRevision();
JToken jtoken;
if (from.TryGetValue(IdField, out jtoken))
{
to.SetId(id);
}
if (from.TryGetValue(KeyField, out jtoken))
{
to.SetKey(key);
}
if (from.TryGetValue(RevisionField, out jtoken))
{
to.SetRevision(revision);
}
}
示例2: RetreiveObjectFromRow
private JObject RetreiveObjectFromRow(DataRow row, bool diffOnly = false)
{
int? pk = row.Field<int?>(this.Table.Columns[KeyColumn]);
string modelName = row.Field<string>(this.Table.Columns[ModelColumn]);
JObject obj = new JObject();
obj.Add(FieldsField, new JObject());
if (pk != null)
obj.SetId(pk ?? 0);
if (modelName == null)
throw new Exception("Error, model must be set for data field");
obj.SetModel(modelName);
if (this.ModelMappings.ContainsKey(modelName))
{
Dictionary<string, string> tableToModel = this.ModelMappings[modelName].TableToModel;
EntityModel model = DonationModels.GetModel(modelName);
foreach (string col in this.Columns)
{
JObject found = null;
if (obj.GetId() != null)
this.CachedObjectTable.TryGetValue(new Tuple<string, int?>(obj.GetModel(), obj.GetId()), out found);
string fieldName = tableToModel[col];
string value = row[this.TrueColumnName(col)] == null ? null : row[this.TrueColumnName(col)].ToString();
if (!model.GetField(fieldName).ReadOnly && (!diffOnly || found == null || !Util.EqualsEx(found.GetField(fieldName), value)))
obj.SetField(fieldName, value);
}
return obj;
}
else
throw new Exception("Model mapping for " + modelName + " unregistered");
}
示例3: AddRow
public void AddRow(JObject dataObj)
{
int? primaryKey = dataObj.GetId();
string modelName = dataObj.GetModel();
if (primaryKey != null)
{
foreach (DataRow row in this.Table.Rows)
{
if (row[ModelColumn].ToString().IEquals(modelName) && row[KeyColumn].ToString().Equals(primaryKey.ToString()))
{
this.FillObjectToRow(row, dataObj);
return;
}
}
}
DataRow newRow = this.Table.Rows.Add(primaryKey, modelName);
this.FillObjectToRow(newRow, dataObj);
}
示例4: FillObjectToRow
private void FillObjectToRow(DataRow row, JObject dataObj)
{
int? primaryKey = dataObj.GetId();
string modelName = dataObj.GetModel();
EntityModel model = DonationModels.GetModel(modelName);
if (this.ModelMappings.ContainsKey(modelName))
{
Dictionary<string,string> tableToModel = this.ModelMappings[modelName].TableToModel;
foreach (string col in this.Columns)
{
string trueColumn = this.TrueColumnName(col);
FieldModel field = model.GetField(tableToModel[col]);
string trueValue = dataObj.GetField(tableToModel[col]);
row[trueColumn] = trueValue;
if (field is EntityFieldModel)
{
EntityFieldModel entityField = field as EntityFieldModel;
EntitySelectionCache cache = this.Context.GetEntitySelectionCache(entityField.ModelName);
cache.RequestRefresh(EntitySelectionCacheRefreshType.Strong);
var mapping = cache.GetLatestCache();
if (trueValue != null)
{
int fk = int.Parse(trueValue);
string name;
if (mapping.TryGetLeftToRight(fk, out name))
row[col] = name;
else
row[col] = row[trueColumn];
}
else
{
row[col] = "";
}
}
else
{
row[col] = trueValue;
}
}
}
else
throw new Exception("Model mapping for " + modelName + " unregistered");
}