当前位置: 首页>>代码示例>>C#>>正文


C# Session.Save方法代码示例

本文整理汇总了C#中Session.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Save方法的具体用法?C# Session.Save怎么用?C# Session.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


在下文中一共展示了Session.Save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixtureSetup

        public void FixtureSetup()
        {
            _cx = ConnectionTests.CreateConnection();
            if (_cx.ListDatabases().Contains("relax-query-tests"))
            {
                _cx.DeleteDatabase("relax-query-tests");
            }
            _cx.CreateDatabase("relax-query-tests");
            _sx = _cx.CreateSession("relax-query-tests");
        
            // populate a few widgets & a simple design doc
            _sx.Save(new Widget { Name = "widget", Manufacturer = "acme" });
            _sx.Save(new Widget { Name = "sprocket", Manufacturer = "acme" });
            _sx.Save(new Widget { Name = "doodad", Manufacturer = "widgetco" });

            _sx.Save(
                new DesignDocument {
                         Language = "javascript",
                         Views = new Dictionary<string, View>
                         {
                            { "all-widgets", new View {
                                Map = @"function(doc) { emit(null, null); }"
                            }},
                            { "all-manufacturers", new View() {
                                Map = @"function(doc) { emit(doc.Manufacturer, 1); }",
                                Reduce = @"function(keys, values, rereduce) { return sum(values); }"
                            }}
                         }
                 },
                 "_design/widgets"
            );      
        }
开发者ID:nicknystrom,项目名称:RedBranch.Hammock,代码行数:32,代码来源:QueryTests.cs

示例2: FixtureSetup

        public void FixtureSetup()
        {
            _cx = ConnectionTests.CreateConnection();
            if (_cx.ListDatabases().Contains("relax-reference-tests"))
            {
                _cx.DeleteDatabase("relax-reference-tests");
            }
            _cx.CreateDatabase("relax-reference-tests");
            _sx = _cx.CreateSession("relax-reference-tests");
            _sx2 = _cx.CreateSession("relax-reference-tests");

            _sx.Save(new Widget { Id = "w1", Name = "Widget", Cost = 30 });
            _sx.Save(new Widget { Id = "w2", Name = "Gadget", Cost = 30 });
            _sx.Save(new Widget { Id = "w3", Name = "Foo",    Cost = 35 });
            _sx.Save(new Widget { Id = "w4", Name = "Bar",    Cost = 35 });
            _sx.Save(new Widget { Id = "w5", Name = "Biz",    Cost = 45 });
            _sx.Save(new Widget { Id = "w6", Name = "Bang",   Cost = 55 });
            
            _sx.SaveRaw(JObject.Parse(
            @"{
                _id: 'g1',
                Name: 'Gadget #1',
                Primary: 'w1'
            }"));
            
            _sx.SaveRaw(JObject.Parse(
            @"{
                _id: 'g2',
                Name: 'Gadget #1',
                Secondary: ['w1', 'w2', 'w3']
            }"));

        }
开发者ID:nicknystrom,项目名称:RedBranch.Hammock,代码行数:33,代码来源:ReferenceTests.cs

示例3: Log

 protected void Log(Exception exception) {
     if (IsEnabled() ) {
         if (EmailTraceListenersAreValid()) {
             string asString = Tracing.Tracer.GetLastEntriesAsString();
             Logger.Write(asString);
         }
         var connectionStringSettingsCollection = ConfigurationManager.ConnectionStrings;
         var connectionStringSettings = connectionStringSettingsCollection.OfType<ConnectionStringSettings>().Where(settings => settings.Name=="ExceptionHandlingConnectionString").FirstOrDefault();
         if (connectionStringSettings!= null) {
             if (XafTypesInfo.Instance.FindTypeInfo(typeof(IExceptionObject)).Implementors.Count() == 0) return;
             var session = new Session(
                 new SimpleDataLayer(XpoDefault.GetConnectionProvider(connectionStringSettings.ConnectionString,AutoCreateOption.DatabaseAndSchema)));
             var exceptionObject = ExceptionObjectBuilder.Create(session,exception,Application);
             session.Save(exceptionObject);
         }
     }
 }
开发者ID:krazana,项目名称:eXpand,代码行数:17,代码来源:ExceptionHandlingModule.cs

示例4: SynchronizeTypesCore

 void SynchronizeTypesCore(XPObjectType xpObjectType, Session session) {
     if (session.FindObject<XPObjectType>(objectType => objectType.TypeName == xpObjectType.TypeName) == null) {
         var objectType = new XPObjectType(session, xpObjectType.AssemblyName, xpObjectType.TypeName);
         session.Save(objectType);
     }
 }
开发者ID:noxe,项目名称:eXpand,代码行数:6,代码来源:TypeSynchronizer.cs

示例5: Populate

        public void Populate(params Assembly[] dataFixtureAssemblies)
        {
            var fixtureContainer = new FixtureContainer();

            foreach (var dataFixtureType in dataFixtureAssemblies.SelectMany(dataFixtureAssembly => dataFixtureAssembly.GetTypes().Where(t => typeof (DataFixture).IsAssignableFrom(t))))
                fixtureContainer.AddDataFixture((DataFixture) Activator.CreateInstance(dataFixtureType));

            var fixtureVertices = fixtureContainer.All.ToDictionary(fixture => fixture.GetType(), fixture => new Vertex(() =>
            {
                using (var session = new Session(_sessionFactory.OpenSession()))
                using (var transaction = session.BeginTransaction())
                {
                    foreach (var entity in fixture.GetEntities(fixtureContainer))
                        session.Save(entity);

                    transaction.Commit();
                }
            }));

            foreach (var dataFixtureType in fixtureVertices.Keys)
            {
                var dataFixture = fixtureContainer.Get(dataFixtureType);
                var vertex = fixtureVertices[dataFixtureType];

                vertex.AddDependencies(dataFixture.Dependencies.Select(d => fixtureVertices[d]).ToArray());
            }

            var graph = new DirectedAcyclicGraph(fixtureVertices.Values);
            var graphExecutive = new ConcurrentGraphExecutive(graph);

            graphExecutive.ExecuteAndWait();

            if (graphExecutive.VerticesFailed.Any())
                throw new AggregateException(graphExecutive.VerticesFailed.Select(e=>e.Value));
        }
开发者ID:myles-mcdonnell,项目名称:Bootstrap4NHibernate,代码行数:35,代码来源:Database.cs

示例6: SynchronizeTypes

        void SynchronizeTypes(UnitOfWork unitOfWork) {
            var xpObjectTypes = new XPCollection<XPObjectType>(unitOfWork);
            var dataStoreManager = new SqlMultiDataStoreProxy(ConnectionString);
            foreach (var xpObjectType in xpObjectTypes) {
                var type = ReflectionHelper.FindType(xpObjectType.TypeName);
                if (type != null) {
                    var connectionString = dataStoreManager.DataStoreManager.GetConnectionString(type);
                    var sqlDataStoreProxy = new SqlDataStoreProxy(connectionString);
                    var xpoObjectHacker = new XpoObjectHacker();
                    XPObjectType type1 = xpObjectType;
                    var simpleDataLayer = new SimpleDataLayer(sqlDataStoreProxy);
                    var session = new Session(simpleDataLayer);
                    bool sync = false;
                    sqlDataStoreProxy.DataStoreModifyData += (sender, args) => {
                        var insertStatement = args.ModificationStatements.OfType<InsertStatement>().Where(statement => statement.TableName == typeof(XPObjectType).Name).SingleOrDefault();
                        if (insertStatement != null && !sync) {
                            sync = true;
                            xpoObjectHacker.CreateObjectTypeIndetifier(insertStatement, simpleDataLayer, type1.Oid);
                            ModificationResult modificationResult = sqlDataStoreProxy.ModifyData(insertStatement);
                            args.ModificationResult = modificationResult;
                            args.ModificationResult.Identities = new[] { new ParameterValue { Value = type1.Oid }, };
                        }
                    };

                    if (session.FindObject<XPObjectType>(objectType => objectType.TypeName == type1.TypeName) == null) {
                        var objectType = new XPObjectType(session, xpObjectType.AssemblyName, xpObjectType.TypeName);
                        session.Save(objectType);

                    }
                }
            }
        }
开发者ID:gvilas,项目名称:eXpand,代码行数:32,代码来源:WorldCreatorModuleBase.cs


注:本文中的Session.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。