本文整理汇总了C#中DataContext.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# DataContext.GetType方法的具体用法?C# DataContext.GetType怎么用?C# DataContext.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataContext
的用法示例。
在下文中一共展示了DataContext.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetData
public static GridDataModel GetData(DataContext db, string type, string columns, int page, int count, List<string> filter, string sort, string sortdir)
{
var ass = db.GetType().Assembly; //haha ass
Type dbType = ass.GetType(type);
var items = (IQueryable)db.GetType().GetMethod("GetTable").MakeGenericMethod(dbType).Invoke(db, null);
return GetData(items, columns, page, count, filter, sort, sortdir);
}
示例2: CreateTable
public virtual object CreateTable(Type rowType, DataContext context)
{
object table = null;
var pluralInflections = MapPluralInflections();
var pluralizedName = rowType.Name + "s";
if (pluralInflections.ContainsKey(rowType.Name))
{
pluralizedName = pluralInflections[rowType.Name].ToString();
}
var property = context.GetType().GetProperty(pluralizedName);
if (property == null)
{
throw new MissingMemberException(context.GetType().FullName, pluralizedName);
}
table = property.GetValue(context, null);
return table;
}
示例3: GetTable
/// <exclude />
internal static ITable GetTable(DataContext _dataContext, SqlDataTypeStoreTable storeInformation)
{
FieldInfo fi = storeInformation.DataContextQueryableFieldInfo;
Verify.IsNotNull(fi, "Missing FieldInfo for a DataContext field.");
object value = fi.GetValue(_dataContext);
if(value == null)
{
var helperClassFieldInfo =_dataContext.GetType().GetField("_sqlDataContextHelperClass", BindingFlags.NonPublic | BindingFlags.Instance);
Verify.IsNotNull(helperClassFieldInfo, "Helper field isn't exist in DataContext object.");
var helper = helperClassFieldInfo.GetValue(_dataContext) as SqlDataContextHelperClass;
Verify.That(helper != null, "Helper object has not been set");
helper.EnsureTableInitialized(fi.Name);
value = helper._tables[fi.Name];
}
return Verify.ResultNotNull(value as ITable);
}
示例4: ResourceContainerToQueryable
public override IQueryable ResourceContainerToQueryable(ResourceContainer container)
{
//Get Lts Type
Type type = this._resourceTypeToWorkspaceTypeList[container.BaseType];
DataContext context = new DataContext(this.Database.DatabaseConnectionString);
MethodInfo method = context.GetType().GetMethod("GetTable", new Type[] { });
MethodInfo genMethod = method.MakeGenericMethod(new Type[] { type });
object o = genMethod.Invoke(context, new object[] { });
if (container.HasInterceptorExpression)
{
o = ApplyQueryInterceptorExpression(container, o as IQueryable);
}
return (IQueryable)o;
}
示例5: GetProvider
private static object GetProvider(DataContext dataContext)
{
Type contextType = dataContext.GetType();
PropertyInfo providerProperty = contextType.GetProperty("Provider", BindingFlags.Instance | BindingFlags.NonPublic);
if (providerProperty == null)
return null;
return providerProperty.GetValue(dataContext, null);
}