Ejemplo n.º 1
0
 /// <summary>  Constructor</summary>
 /// <param name="name">The application-defined field name
 /// </param>
 /// <param name="type">A constant from the System.Data.DbType enumeration. The type is used
 /// by SQLQueryBuilder to property format the field value
 /// </param>
 public SQLField( string name,
                  DbType type )
 {
     fName = name;
     fDbType = type;
     fDialect = SqlDialect.DEFAULT;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 /// <param name="type"></param>
 /// <param name="dialect"></param>
 public SQLField(string name,
          DbType type, Dialect dialect)
 {
     fName = name;
     fDbType = type;
     fDialect = dialect;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds SQLFields to represent each field rule in the specified MappingsContext
        /// </summary>
        /// <param name="context"></param>
        /// <param name="dialect"></param>
        public void AddFields( MappingsContext context, Dialect dialect )
        {
            foreach ( FieldMapping mapping in context.FieldMappings )
            {
                Rule rule = mapping.fRule;
                if ( rule is XPathRule )
                {
                    TypeConverter converter = null;
                    XPathRule xRule = (XPathRule) rule;
                    IElementDef targetDef = xRule.LookupTargetDef( context.ObjectDef );
                    if ( targetDef != null )
                    {
                        converter = targetDef.TypeConverter;
                    }
                    if ( converter == null )
                    {
                        converter = SifTypeConverters.STRING;
                    }
                    if ( mapping.ValueSetID != null )
                    {
                        ValueSet vs = context.Mappings.GetValueSet( mapping.ValueSetID, true );
                        if ( vs != null )
                        {
                            //Create the lookup table for generating the SQL lookup
                            StringBuilder buffer = new StringBuilder();
                            // e.g. CircRecord.PatronType{StudentPersonal=1;StaffPersonal=2}
                            //buffer.Append( tablePrefix );
                            buffer.Append( mapping.FieldName );
                            buffer.Append( '{' );
                            ValueSetEntry[] entries = vs.Entries;
                            for ( int a = 0; a < entries.Length; a++ )
                            {
                                if ( a > 0 )
                                {
                                    buffer.Append( ';' );
                                }
                                buffer.Append( entries[a].Value );
                                buffer.Append( '=' );
                                ;
                                buffer.Append( entries[a].Name );
                            }
                            buffer.Append( '}' );
                            SQLField f = new SQLField( buffer.ToString(), converter.DbType, dialect );
                            AddField( xRule.XPath, f );
                            continue;
                        }
                    }

                    SQLField field = new SQLField( mapping.FieldName, converter.DbType, dialect );
                    AddField( xRule.XPath, field );
                }
            }
        }