当前位置: 首页>>代码示例>>C#>>正文


C# DataContext.GetType方法代码示例

本文整理汇总了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);
        }
开发者ID:ArdentLeisure,项目名称:DataGrid,代码行数:10,代码来源:GridHelper.cs

示例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;
        }
开发者ID:alpsantos,项目名称:linq-to-sql-template-repository,代码行数:24,代码来源:RowFactory.cs

示例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);
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:21,代码来源:SqlDataContextHelperClass.cs

示例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;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:18,代码来源:LinqToSqlWorkspace.cs

示例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);
        }
开发者ID:mattfrerichs,项目名称:Templates,代码行数:9,代码来源:DataContextExtensions.cs


注:本文中的DataContext.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。