private static void CopyPropsToNewObjectInfoProperties(
     DataObject obj,
     IEnumerable <MetadataProperty> metaProps,
     IDictionary <MetadataProperty, object> values)
 {
     StorageCommitPlan.CopyPropValues(obj, metaProps, values);
 }
        private void CommitNewObjectsToDb(ObjectsByPropertyIndexSet plan)
        {
            List <MetadataProperty> metaProps = this.GetMetaProps(plan.IndexSet);
            StringBuilder           sql       = new StringBuilder(string.Format("INSERT INTO [{0}]([{1}]", (object)this.FClass.DataTable, (object)this.FClass.IDProperty.DataField));
            int paramIndex1 = 1;

            StorageCommitPlan.MetaPropsToSql((IList <MetadataProperty>)metaProps, sql, ",", "[{0}]", (DataType[])null, ref paramIndex1);
            sql.Append(") VALUES (?");
            DataType[] paramTypes = new DataType[paramIndex1];
            object[]   values     = new object[paramIndex1];
            paramTypes[0] = DataType.String;
            int paramIndex2 = 1;

            StorageCommitPlan.MetaPropsToSql((IList <MetadataProperty>)metaProps, sql, ",", "?", paramTypes, ref paramIndex2);
            sql.Append(")");
            InDbCommand command = this.FSession.Db.CreateCommand(sql.ToString(), paramTypes);

            try
            {
                for (int index1 = 0; index1 < plan.Count; ++index1)
                {
                    DataObject dataObject = plan[index1];
                    int        index2     = 1;
                    values[0] = (object)dataObject.Id.ToString();
                    StorageCommitPlan.CopyPropsToParams(dataObject, (IList <MetadataProperty>)metaProps, values, ref index2);
                    command.Execute(values);
                }
            }
            finally
            {
                command.Dispose();
            }
        }
        private void AddModifiedObjectInfos(
            ObjectsByPropertyIndexSet plan,
            ICollection <ModifiedObjectInfo> modifiedObjects)
        {
            List <MetadataProperty> metaProps = this.GetMetaProps(plan.IndexSet);

            for (int index = 0; index < plan.Count; ++index)
            {
                DataObject         dataObject         = plan[index];
                ModifiedObjectInfo modifiedObjectInfo = new ModifiedObjectInfo(dataObject.Id.ToString());
                StorageCommitPlan.CopyPropsToModifiedObjectInfoProperties(dataObject, (IEnumerable <MetadataProperty>)metaProps, (IDictionary <MetadataProperty, object>)modifiedObjectInfo.Properties);
                modifiedObjects.Add(modifiedObjectInfo);
            }
        }
 private static void CopyPropsToParams(
     DataObject obj,
     IList <MetadataProperty> metaProps,
     object[] values,
     ref int index)
 {
     for (int index1 = 0; index1 < metaProps.Count; ++index1)
     {
         MetadataProperty metaProp = metaProps[index1];
         if (!metaProp.IsId && !metaProp.IsSelector)
         {
             StorageCommitPlan.CopyPropToParam(obj, metaProp, values, ref index);
         }
     }
 }
 private static void MetaPropsToSql(
     IList <MetadataProperty> metaProps,
     StringBuilder sql,
     string divider,
     string format,
     DataType[] paramTypes,
     ref int paramIndex)
 {
     for (int index = 0; index < metaProps.Count; ++index)
     {
         MetadataProperty metaProp = metaProps[index];
         if (!metaProp.IsId && !metaProp.IsSelector)
         {
             StorageCommitPlan.MetaPropToSql(metaProp, sql, divider, format, ref paramIndex, paramTypes);
             divider = ",";
             if (metaProp.IsLink && metaProp.Association.Selector != null)
             {
                 StorageCommitPlan.MetaPropToSql(metaProp.Association.Selector, sql, divider, format, ref paramIndex, paramTypes);
             }
         }
     }
 }
 private static void CopyPropValues(
     DataObject dataObject,
     IEnumerable <MetadataProperty> metaProps,
     IDictionary <MetadataProperty, object> properties)
 {
     foreach (MetadataProperty metaProp in metaProps)
     {
         if (!metaProp.IsId && !metaProp.IsSelector)
         {
             MetadataProperty prop1;
             object           obj1;
             MetadataProperty prop2;
             object           obj2;
             StorageCommitPlan.GetPropValues(dataObject, metaProp, out prop1, out obj1, out prop2, out obj2);
             properties.Add(prop1, obj1);
             if (prop2 != null)
             {
                 properties.Add(prop2, obj2);
             }
         }
     }
 }
 private void CommitUpdatingToMasterSession(IEnumerable <ObjectsByPropertyIndexSet> updatePlan)
 {
     foreach (ObjectsByPropertyIndexSet propertyIndexSet in updatePlan)
     {
         if (propertyIndexSet.IndexSet.IsEmpty)
         {
             break;
         }
         List <MetadataProperty> metadataPropertyList = new List <MetadataProperty>();
         IndexSet indexSet = propertyIndexSet.IndexSet;
         for (int index = 0; index < this.FStorage.Class.Properties.Count; ++index)
         {
             if (indexSet[index])
             {
                 metadataPropertyList.Add(this.FStorage.Class.Properties[index]);
             }
         }
         for (int index = 0; index < propertyIndexSet.Count; ++index)
         {
             DataObject dataObject = propertyIndexSet[index];
             StorageCommitPlan.CopyPropsToMasterObject(dataObject, this.FMasterStorage[dataObject.Id], (IList <MetadataProperty>)metadataPropertyList);
         }
     }
 }
        private void CommitModifiedObjectsToDb(ObjectsByPropertyIndexSet plan)
        {
            if (plan.IndexSet.IsEmpty)
            {
                return;
            }
            List <MetadataProperty> metaProps = this.GetMetaProps(plan.IndexSet);
            StringBuilder           sql       = new StringBuilder(string.Format("UPDATE [{0}] SET ", (object)this.FClass.DataTable));
            int paramIndex1 = 0;

            StorageCommitPlan.MetaPropsToSql((IList <MetadataProperty>)metaProps, sql, (string)null, "[{0}]=?", (DataType[])null, ref paramIndex1);
            sql.Append(string.Format(" WHERE [{0}]=?", (object)this.FClass.IDProperty.DataField));
            DataType[] paramTypes  = new DataType[paramIndex1 + 1];
            object[]   values      = new object[paramIndex1 + 1];
            int        paramIndex2 = 0;

            StorageCommitPlan.MetaPropsToSql((IList <MetadataProperty>)metaProps, (StringBuilder)null, (string)null, (string)null, paramTypes, ref paramIndex2);
            paramTypes[paramIndex2] = DataType.String;
            InDbCommand command = this.FSession.Db.CreateCommand(sql.ToString(), paramTypes);

            try
            {
                for (int index1 = 0; index1 < plan.Count; ++index1)
                {
                    DataObject dataObject = plan[index1];
                    int        index2     = 0;
                    StorageCommitPlan.CopyPropsToParams(dataObject, (IList <MetadataProperty>)metaProps, values, ref index2);
                    values[index2] = (object)dataObject.Id.ToString();
                    command.Execute(values);
                }
            }
            finally
            {
                command.Dispose();
            }
        }