Beispiel #1
0
 public ReferenceInfo(MetaInfoStore metaInfoStore, string name, Type referenceType, PropertyInfo propertyInfo)
     : base(metaInfoStore, name,
            metaInfoStore.GetTableInfoFor(referenceType).PrimaryKey.DotNetType,
            metaInfoStore.GetTableInfoFor(referenceType).PrimaryKey.DbType, metaInfoStore.GetTableInfoFor(referenceType).PrimaryKey.SqlDbType, propertyInfo)
 {
     ReferenceType = referenceType;
 }
Beispiel #2
0
        private List <AdoParameterInfo> GetParametersForReferenceAndRegularColumns(object entity)
        {
            var parameters = new List <AdoParameterInfo>();

            foreach (ReferenceInfo referenceInfo in References)
            {
                object       referencedEntity            = referenceInfo.PropertyInfo.GetValue(entity, null);
                PropertyInfo referencePrimaryKeyProperty =
                    MetaInfoStore.GetTableInfoFor(referenceInfo.ReferenceType).PrimaryKey.PropertyInfo;
                if (referencedEntity == null)
                {
                    parameters.Add(new AdoParameterInfo(referenceInfo.Name, referenceInfo.DbType, null));
                }
                else
                {
                    parameters.Add(new AdoParameterInfo(referenceInfo.Name, referenceInfo.DbType,
                                                        referencePrimaryKeyProperty.GetValue(referencedEntity, null)));
                }
            }

            foreach (ColumnInfo columnInfo in ColumnInfos)
            {
                MemberTypes memberType = columnInfo.PropertyInfo.MemberType;

                TestMethod(entity, columnInfo.PropertyInfo);
                object val = columnInfo.PropertyInfo.GetValue(entity, null);

                parameters.Add(new AdoParameterInfo(columnInfo.Name, columnInfo.DbType,
                                                    columnInfo.PropertyInfo.GetValue(entity, null)));
            }
            return(parameters);
        }