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


C# NHibernate.Query方法代码示例

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


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

示例1: ValidarNome

        private void ValidarNome(Visao visao, NHibernate.ISession session)
        {
            var qdtVisoesComMesmoNome = session.Query<Visao>()
                .Count(i => i.Nome.Equals(visao.Nome) && (i.Id != visao.Id));

            if (qdtVisoesComMesmoNome > 0)
                throw new BLLException("Esse nome já está sendo usado por outra visão");
        }
开发者ID:GabrielMCardozo,项目名称:Sind,代码行数:8,代码来源:ManterVisao.cs

示例2: createTestPeptideInstances

        private static void createTestPeptideInstances (NHibernate.ISession session, BulkInserter bulkInserter, Peptide pep)
        {
            // store instances even though the association is inverse:
            // the PeptideModification.Offset property needs access to the protein sequence
            pep.Instances = new List<PeptideInstance>();

            foreach (Protein pro in session.Query<Protein>())
            {
                int start = pro.Sequence.IndexOf(pep.Sequence, 0);
                while (start >= 0)
                {
                    int end = start + pep.Sequence.Length;
                    bool nTerminusIsSpecific = start == 0 || pro.Sequence[start - 1] == 'K' || pro.Sequence[start - 1] == 'R';
                    bool cTerminusIsSpecific = end == pro.Sequence.Length || pro.Sequence[end - 1] == 'K' || pro.Sequence[end - 1] == 'R';
                    var instance = new TestPI()
                    {
                        Peptide = pep,
                        Protein = pro,
                        Offset = start,
                        Length = pep.Sequence.Length,
                        MissedCleavages = pep.Sequence.ToCharArray(0, pep.Sequence.Length - 1).Count(o => o == 'K' || o == 'R'),
                        NTerminusIsSpecific = nTerminusIsSpecific,
                        CTerminusIsSpecific = cTerminusIsSpecific,
                    };

                    var instanceAccessor = new PrivateObject(instance);
                    instanceAccessor.SetProperty("SpecificTermini", (nTerminusIsSpecific ? 1 : 0) + (cTerminusIsSpecific ? 1 : 0));

                    bulkInserter.Add(instance);
                    pep.Instances.Add(instance);

                    start = pro.Sequence.IndexOf(pep.Sequence, start + 1);
                }
            }

            if (pep.Instances.Count == 0)
                throw new ArgumentException("peptide " + pep.Sequence + " does not occur in any proteins");
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:38,代码来源:TestModel.cs

示例3: AddSubsetPeakData

        public static void AddSubsetPeakData (NHibernate.ISession session)
        {
            session.Transaction.Begin();
            session.Clear();
            foreach (SpectrumSource source in session.Query<SpectrumSource>())
            {
                var subsetPeakData = new msdata.MSData();
                subsetPeakData.id = subsetPeakData.run.id = source.Name;
                var spectrumList = new msdata.SpectrumListSimple();
                subsetPeakData.run.spectrumList = spectrumList;

                foreach (Spectrum spectrum in source.Spectra.OrderBy(o => o.Index))
                {
                    var spectrumData = new msdata.Spectrum();
                    spectrumData.id = spectrum.NativeID;
                    spectrumData.index = spectrum.Index;
                    spectrumData.setMZIntensityArrays(new List<double>() { 100, 200, 300, 400, 500 },
                                                      new List<double>() { 10, 20, 30, 40, 50 });
                    spectrumList.spectra.Add(spectrumData);
                }

                session.Evict(source);
                var newSource = new SpectrumSource(subsetPeakData)
                {
                    Id = source.Id,
                    Group = source.Group,
                    Name = source.Name,
                    URL = source.URL
                };
                session.Update(newSource);
            }
            session.Transaction.Commit();
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:33,代码来源:TestModel.cs

示例4: CreateTestData

        public static void CreateTestData (NHibernate.ISession session, IList<SpectrumTuple> testPsmSummary)
        {
            var dbGroups = new Map<string, SpectrumSourceGroup>();
            foreach (var ssg in session.Query<SpectrumSourceGroup>())
                dbGroups[ssg.Name] = ssg;

            var dbSources = new Map<long, SpectrumSource>();
            foreach (var ss in session.Query<SpectrumSource>())
                dbSources[ss.Id.Value] = ss;

            var dbAnalyses = new Map<long, Analysis>();
            foreach (var a in session.Query<Analysis>())
                dbAnalyses[a.Id.Value] = a;

            var dbPeptides = new Map<string, Peptide>();
            foreach (var pep in session.Query<Peptide>())
                dbPeptides[pep.Sequence] = pep;

            var bulkInserter = new BulkInserter(session.Connection);

            long lastPsmId = session.CreateQuery("SELECT MAX(Id) FROM PeptideSpectrumMatch").UniqueResult<long?>().GetValueOrDefault();
            long lastModId = session.CreateQuery("SELECT MAX(Id) FROM Modification").UniqueResult<long?>().GetValueOrDefault();
            long lastPmId = session.CreateQuery("SELECT MAX(Id) FROM PeptideModification").UniqueResult<long?>().GetValueOrDefault();
            long lastGroupId = session.CreateQuery("SELECT MAX(Id) FROM SpectrumSourceGroup").UniqueResult<long?>().GetValueOrDefault();
            long lastSourceId = session.CreateQuery("SELECT MAX(Id) FROM SpectrumSource").UniqueResult<long?>().GetValueOrDefault();
            long lastSglId = session.CreateQuery("SELECT MAX(Id) FROM SpectrumSourceGroupLink").UniqueResult<long?>().GetValueOrDefault();

            foreach (SpectrumTuple row in testPsmSummary)
            {
                string groupName = row.Group;
                string sourceName = "Source " + row.Source;
                string analysisId = "Engine " + row.Analysis;
                string peptideTuples = row.PeptideTuples;

                SpectrumSourceGroup group = dbGroups[groupName];
                if (String.IsNullOrEmpty(group.Name))
                {
                    group.Id = ++lastGroupId;
                    group.Name = groupName;
                    bulkInserter.Add(group);
                }

                SpectrumSource source = dbSources[row.Source];
                if (String.IsNullOrEmpty(source.Name))
                {
                    source.Id = ++lastSourceId;
                    source.Name = sourceName;
                    source.Group = group;
                    source.Spectra = new List<Spectrum>();
                    bulkInserter.Add(source);

                    // add a source group link for the source's immediate group
                    bulkInserter.Add(new SpectrumSourceGroupLink() { Id = ++lastSglId, Group = group, Source = source });

                    #region add source group links for all of the immediate group's parent groups

                    if (groupName != "/")
                    {
                        string parentGroupName = groupName.Substring(0, groupName.LastIndexOf("/"));
                        while (true)
                        {
                            if (String.IsNullOrEmpty(parentGroupName))
                                parentGroupName = "/";

                            // add the parent group if it doesn't exist yet
                            SpectrumSourceGroup parentGroup = session.UniqueResult<SpectrumSourceGroup>(o => o.Name == parentGroupName);
                            if (parentGroup == null)
                            {
                                parentGroup = new SpectrumSourceGroup() { Id = ++lastGroupId, Name = parentGroupName };
                                bulkInserter.Add(parentGroup);
                            }

                            bulkInserter.Add(new SpectrumSourceGroupLink() { Id = ++lastSglId, Group = parentGroup, Source = source });

                            if (parentGroupName == "/")
                                break;
                            parentGroupName = parentGroupName.Substring(0, parentGroupName.LastIndexOf("/"));
                        }
                    }

                    #endregion
                }

                Spectrum spectrum = source.Spectra.SingleOrDefault(o => o.Source.Id == source.Id &&
                                                                        o.Index == row.Spectrum - 1);
                if (spectrum == null)
                {
                    spectrum = new Spectrum()
                                   {
                                       Id = source.Id * 10000 + row.Spectrum,
                                       Index = row.Spectrum - 1,
                                       NativeID = "scan=" + row.Spectrum,
                                       Source = source,
                                       PrecursorMZ = 42
                                   };
                    source.Spectra.Add(spectrum);
                    bulkInserter.Add(spectrum);
                }

                Analysis analysis = dbAnalyses[row.Analysis];
//.........这里部分代码省略.........
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:TestModel.cs

示例5: ValidarSigla

        private void ValidarSigla(Filial filial, NHibernate.ISession session)
        {
            var qdtFiliaisComMesmaSigla = session.Query<Filial>()
                .Count(i => i.Sigla.Equals(filial.Sigla));

            if (qdtFiliaisComMesmaSigla > 0)
                throw new BLLException("Essa sigla já está sendo usada por outra filial");
        }
开发者ID:GabrielMCardozo,项目名称:Sind,代码行数:8,代码来源:ManterFilial.cs

示例6: ValidarNome

        private void ValidarNome(Filial filial, NHibernate.ISession session)
        {
            var qdtFiliaisComMesmoNome = session.Query<Filial>()
                .Count(i => i.Nome.Equals(filial.Nome));

            if (qdtFiliaisComMesmoNome > 0)
                throw new BLLException("Esse nome já está sendo usado por outra filial");
        }
开发者ID:GabrielMCardozo,项目名称:Sind,代码行数:8,代码来源:ManterFilial.cs


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