private void GetFeaturesAndAddAttachment()
        {
            // TODO
            // open the file geodatabase c:\ProSDKWorkshop\data\generic.gdb
            using (Geodatabase geodatabase = new Geodatabase(@"c:\ProSDKWorkshop\data\generic.gdb"))
            {
                using (FeatureClass pointFeatureClass = geodatabase.OpenDataset <FeatureClass>("SamplePoints"))
                {
                    using (RowCursor features = pointFeatureClass.Search())
                    {
                        while (features.MoveNext())
                        {
                            Feature currentFeature = features.Current as Feature;
                            currentFeature.AddAttachment(new Attachment("SamplePicture", "image/png",
                                                                        CreateMemoryStreamFromContentsOf(@"C:\ProSDKWorkshop\data\redlands.png")));
                        }
                    }
                }
            }

            // TODO
            // open the SamplePoints feature class

            // TODO
            // retrieve all features by searching the feature class

            // TODO
            // for each feature add the attachment

            // TODO
            // add the sample picture as an attachment

            // add the feature class as a layer to the active map
            LayerFactory.CreateFeatureLayer(new Uri(@"c:\ProSDKWorkshop\data\generic.gdb\SamplePoints"), MapView.Active.Map);
        }
        private void MainMethodCode()
        {
            using (Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb"))))
                using (Table inspectionTable = fileGeodatabase.OpenDataset <Table>("luCodeInspection"))
                {
                    QueryFilter queryFilter = new QueryFilter {
                        WhereClause = "ACTION = '1st Notice'"
                    };

                    using (RowCursor cursor = inspectionTable.Search(queryFilter)) // Using Recycling.
                    {
                        while (cursor.MoveNext())
                        {
                            using (Row currentRow = cursor.Current)
                            {
                                Attachment attachment = new Attachment("NewAttachment.png", "image/png", CreateMemoryStreamFromContentsOf("geodatabaseAttachment.png"));

                                long attachmentId = currentRow.AddAttachment(attachment);
                            }
                        }
                    }
                }

            // Opening a Non-Versioned SQL Server instance.

            DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
            {
                AuthenticationMode = AuthenticationMode.DBMS,

                // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance.
                Instance = @"testMachine\testInstance",

                // Provided that a database called LocalGovernment has been created on the testInstance and geodatabase has been enabled on the database.
                Database = "LocalGovernment",

                // Provided that a login called gdb has been created and corresponding schema has been created with the required permissions.
                User     = "******",
                Password = "******",
                Version  = "dbo.DEFAULT"
            };

            using (Geodatabase geodatabase = new Geodatabase(connectionProperties))
                using (FeatureClass parkFeatureClass = geodatabase.OpenDataset <FeatureClass>("LocalGovernment.GDB.Park"))
                {
                    QueryFilter filter = new QueryFilter {
                        WhereClause = "NUMPARKING > 0"
                    };

                    using (RowCursor parkingCursor = parkFeatureClass.Search(filter, false))
                    {
                        while (parkingCursor.MoveNext())
                        {
                            Feature park = (Feature)parkingCursor.Current;

                            Attachment attachment = new Attachment("Sample.xml", "text/xml", CreateMemoryStreamFromContentsOf("Sample.xml"));

                            long attachmentId = park.AddAttachment(attachment);
                        }
                    }
                }
        }