本文整理汇总了C#中DynamicTable类的典型用法代码示例。如果您正苦于以下问题:C# DynamicTable类的具体用法?C# DynamicTable怎么用?C# DynamicTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DynamicTable类属于命名空间,在下文中一共展示了DynamicTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDelegate
public Func<object[], object> CreateDelegate(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
if (dataStrategy is SimpleTransaction) return null;
if (binder.Name.Equals("FindBy") || binder.Name.Equals("find_by"))
{
if (args.Length == 0) throw new ArgumentException("FindBy requires arguments.");
if (args.Length == 1)
{
if (ReferenceEquals(args[0], null)) throw new ArgumentException("FindBy does not accept unnamed null argument.");
if (args[0].GetType().Namespace == null) return null;
}
}
var criteriaDictionary = CreateCriteriaDictionary(binder, args);
if (criteriaDictionary == null) return null;
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteriaDictionary);
try
{
var adapter = dataStrategy.GetAdapter();
var func = adapter.OptimizingDelegateFactory.CreateFindOneDelegate(adapter, table.GetQualifiedName(), criteriaExpression);
return a =>
{
var data = func(a);
return (data != null && data.Count > 0)
? new SimpleRecord(data, table.GetQualifiedName(), dataStrategy)
: null;
};
}
catch (NotImplementedException)
{
return null;
}
}
示例2: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var criteria = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), MethodNameParser.ParseFromBinder(binder, args));
return new SimpleQuery(dataStrategy.Adapter, table.GetQualifiedName()).Where(criteria);
//var data = dataStrategy.Find(table.GetQualifiedName(), criteria);
//return CreateSimpleResultSet(table, dataStrategy, data);
}
示例3: CreateDelegate
public Func<object[], object> CreateDelegate(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
if (dataStrategy is SimpleTransaction) return null;
if (binder.Name.Equals("FindBy") || binder.Name.Equals("find_by"))
{
ArgumentHelper.CheckFindArgs(args, binder);
if (args.Length == 1 && args[0].IsAnonymous()) return null;
}
var criteriaDictionary = ArgumentHelper.CreateCriteriaDictionary(binder, args, "FindBy", "find_by");
if (criteriaDictionary == null) return null;
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteriaDictionary);
try
{
var adapter = dataStrategy.GetAdapter();
var func = adapter.OptimizingDelegateFactory.CreateFindOneDelegate(adapter, table.GetQualifiedName(), criteriaExpression);
return a =>
{
var data = func(a);
return (data != null && data.Count > 0)
? new SimpleRecord(data, table.GetQualifiedName(), dataStrategy)
: null;
};
}
catch (NotImplementedException)
{
return null;
}
}
示例4: CreateDelegate
public Func<object[], object> CreateDelegate(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
if (dataStrategy is SimpleTransaction) return null;
var criteriaDictionary = CreateCriteriaDictionary(binder, args);
if (criteriaDictionary == null) return null;
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteriaDictionary);
try
{
var adapter = dataStrategy.GetAdapter();
var func = adapter.OptimizingDelegateFactory.CreateFindOneDelegate(adapter, table.GetQualifiedName(), criteriaExpression);
return a =>
{
var data = func(a);
return (data != null && data.Count > 0)
? new SimpleRecord(data, table.GetQualifiedName(), dataStrategy)
: null;
};
}
catch (NotImplementedException)
{
return null;
}
}
示例5: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(),
CreateCriteriaDictionary(binder,
args));
var data = dataStrategy.Run.FindOne(table.GetQualifiedName(), criteriaExpression);
return data != null ? new SimpleRecord(data, table.GetQualifiedName(), dataStrategy) : null;
}
示例6: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var criteria = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), MethodNameParser.ParseFromBinder(binder, args));
var data = dataStrategy.Find(table.GetQualifiedName(), criteria);
return new SimpleResultSet(data != null
? data.Select(dict => new SimpleRecord(dict, table.GetQualifiedName(), dataStrategy))
: Enumerable.Empty<SimpleRecord>());
}
示例7: Execute
/// <summary>
/// Executes the command.
/// </summary>
/// <param name="dataStrategy">The data strategy.</param>
/// <param name="table"></param>
/// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
/// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
/// <returns></returns>
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var criteriaDictionary = ArgumentHelper.CreateCriteriaDictionary(binder, args, "ExistsBy", "exists_by", "AnyBy", "any_by");
if (criteriaDictionary == null) return null;
var criteria = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteriaDictionary);
return new SimpleQuery(dataStrategy, table.GetQualifiedName()).Where(criteria).Exists();
}
示例8: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var result = dataStrategy.Run.Get(table.GetName(), args);
if (result == null || result.Count == 0) return null;
return binder.Name.Equals("get", StringComparison.OrdinalIgnoreCase)
? new SimpleRecord(result, table.GetQualifiedName(), dataStrategy)
: result.First().Value;
}
示例9: loadData
protected override void loadData()
{
var table = new DynamicTable( new EwfTableColumn( "Email", Unit.Percentage( 50 ) ), new EwfTableColumn( "Role", Unit.Percentage( 50 ) ) );
table.AddActionLink( new ActionButtonSetup( "Create User", new EwfLink( new EditUser.Info( es.info, null ) ) ) );
foreach( var user in UserManagementStatics.GetUsers() )
table.AddTextRow( new RowSetup { ClickScript = ClickScript.CreateRedirectScript( new EditUser.Info( es.info, user.UserId ) ) }, user.Email, user.Role.Name );
ph.AddControlsReturnThis( table );
}
示例10: Execute
/// <summary>
/// Executes the command.
/// </summary>
/// <param name="dataStrategy">The database or transaction</param>
/// <param name="table"></param>
/// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
/// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
/// <returns></returns>
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
if (args.Length == 1 && args[0] is SimpleExpression)
{
return new SimpleQuery(dataStrategy, table.GetQualifiedName()).Where((SimpleExpression)args[0]);
}
throw new BadExpressionException("FindAll only accepts a criteria expression.");
}
示例11: UpdateUsingKeys
private static object UpdateUsingKeys(DataStrategy dataStrategy, DynamicTable table, object[] args)
{
var record = ObjectToDictionary(args[0]);
var list = record as IList<IDictionary<string, object>>;
if (list != null) return dataStrategy.UpdateMany(table.GetQualifiedName(), list);
var dict = record as IDictionary<string, object>;
return dataStrategy.Update(table.GetQualifiedName(), dict);
}
示例12: GetCriteriaExpression
private static SimpleExpression GetCriteriaExpression(InvokeMemberBinder binder, object[] args, DynamicTable table)
{
var criteria = binder.Name.Equals("delete", StringComparison.InvariantCultureIgnoreCase) ?
binder.NamedArgumentsToDictionary(args)
:
MethodNameParser.ParseFromBinder(binder, args);
return ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteria);
}
示例13: Execute
/// <summary>
/// Executes the command.
/// </summary>
/// <param name="dataStrategy">The database or transaction</param>
/// <param name="table"></param>
/// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
/// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
/// <returns></returns>
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
if (args.Length == 1 && args[0] is SimpleExpression)
{
return new SimpleQuery(dataStrategy, table.GetQualifiedName()).Where((SimpleExpression)args[0]);
}
return null;
}
示例14: Find_Each_Accepts_Action_Argument
public void Find_Each_Accepts_Action_Argument()
{
var table = new DynamicTable("Users");
var result = table.FindEach(x =>
{
});
}
示例15: Execute
/// <summary>
/// Executes the command.
/// </summary>
/// <param name="dataStrategy">The database (or transaction)</param>
/// <param name="table"></param>
/// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
/// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
/// <returns></returns>
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
if (args.Length == 1 && args[0] is SimpleExpression)
{
var data = dataStrategy.FindOne(table.GetQualifiedName(), (SimpleExpression)args[0]);
return data != null ? new SimpleRecord(data, table.GetQualifiedName(), dataStrategy) : null;
}
return null;
}