public SqlStatement(SqlSelectClause sqlSelectClause, Type parentType, Type childType) { this.m_SqlSelectClause = sqlSelectClause; this.m_SqlFromClause = new SqlFromClause(childType); this.m_SqlWhereClause = new SqlWhereClause(parentType, childType); this.m_SqlForXMLClause = new SqlForXMLClause(childType); }
public SqlStatement(SqlParameterClause sqlParameterClause, SqlSelectClause sqlSelectClause, Type type) { this.m_SqlParameterClause = sqlParameterClause; this.m_SqlSelectClause = sqlSelectClause; this.m_SqlFromClause = new SqlFromClause(type); this.m_SqlWhereClause = new SqlWhereClause(type); this.m_SqlForXMLClause = new SqlForXMLClause(type); }
private void HandlChildCollections(Type type, SqlCommand cmd, SqlSelectClause sqlSelect) { List<PropertyInfo> childCollectionPropertList = type.GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(PersistentCollection))).ToList(); foreach (PropertyInfo propertyInfo in childCollectionPropertList) { Type collectionType = propertyInfo.PropertyType; Type baseType = collectionType.BaseType; Type genericType = baseType.GetGenericArguments()[0]; SqlSelectClause thisSqlSelect = new SqlSelectClause(collectionType); SqlStatement sqlStatement = new SqlStatement(thisSqlSelect, type, genericType); sqlSelect.SqlStatements.Add(sqlStatement); this.HandlChildCollections(genericType, cmd, thisSqlSelect); } }
private void HandlChildCollections(Type type, SqlCommand cmd, SqlSelectClause sqlSelect) { List <PropertyInfo> childCollectionPropertList = type.GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(PersistentCollection))).ToList(); foreach (PropertyInfo propertyInfo in childCollectionPropertList) { Type collectionType = propertyInfo.PropertyType; Type baseType = collectionType.BaseType; Type genericType = baseType.GetGenericArguments()[0]; SqlSelectClause thisSqlSelect = new SqlSelectClause(collectionType); SqlStatement sqlStatement = new SqlStatement(thisSqlSelect, type, genericType); sqlSelect.SqlStatements.Add(sqlStatement); this.HandlChildCollections(genericType, cmd, thisSqlSelect); } }
public SqlCommand Build() { SqlCommand cmd = new SqlCommand(); PersistentClass persistentClassAttribute = (PersistentClass)this.m_Type.GetCustomAttributes(typeof(PersistentClass), false).Single(); PropertyInfo primaryKeyPropertyInfo = this.m_Type.GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(PersistentPrimaryKeyProperty))).Single(); StringPropertyBridge primaryKeyPropertyBridge = new StringPropertyBridge(primaryKeyPropertyInfo, this.m_PrimaryKeyValue); primaryKeyPropertyBridge.SetSqlParameter(cmd); SqlSelectClause sqlSelect = new SqlSelectClause(this.m_Type); SqlParameterClause sqlParameterStatement = new SqlParameterClause(this.m_Type, this.m_PrimaryKeyValue); SqlStatement sqlStatement = new SqlStatement(sqlParameterStatement, sqlSelect, this.m_Type); cmd.CommandText = sqlStatement.ToString(); return cmd; }
public SqlCommand Build() { SqlCommand cmd = new SqlCommand(); PersistentClass persistentClassAttribute = (PersistentClass)this.m_Type.GetCustomAttributes(typeof(PersistentClass), false).Single(); PropertyInfo primaryKeyPropertyInfo = this.m_Type.GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(PersistentPrimaryKeyProperty))).Single(); StringPropertyBridge primaryKeyPropertyBridge = new StringPropertyBridge(primaryKeyPropertyInfo, this.m_PrimaryKeyValue); primaryKeyPropertyBridge.SetSqlParameter(cmd); SqlSelectClause sqlSelect = new SqlSelectClause(this.m_Type); SqlParameterClause sqlParameterStatement = new SqlParameterClause(this.m_Type, this.m_PrimaryKeyValue); SqlStatement sqlStatement = new SqlStatement(sqlParameterStatement, sqlSelect, this.m_Type); cmd.CommandText = sqlStatement.ToString(); return(cmd); }