惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
D
Docker
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
月光博客
月光博客
小众软件
小众软件
量子位
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
罗磊的独立博客
博客园 - 叶小钗
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
博客园 - 司徒正美
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
Hugging Face - Blog
Hugging Face - Blog
GbyAI
GbyAI
C
Check Point Blog

博客园 - mahope

一个算法题解 在ASP.NET web 站点中使用log4net (1.2.9) 在.NET 中实现 AOP 解决Web Service中传递子类实例时,序列化的问题。 Q & A:Does ASP.NET support one-way Web Service operations? openwave:Malformed server response web 项目的 csproj 文件要有对应的.webinfo文件才能在vs里面打开 - mahope 软件需求规范(SRS)指南 写需求文档的一般原则 删除everyone对c:的 访问权限后,运行asp.net出现DirectoryNotFoundException未找到路径“C:\”的一部分 - mahope - 博客园 NHibernate Mapping文件中如何指定类的字节数组属性 NHibernate.ADOException : Unable to perform find 对于事件不能调用BeginInvoke,可改用另外一层包装 IBM面试题试解(关于50条狗、50个人、病狗) Einstein's Riddle 爱因斯坦出的智力题? Artificial intelligence: Solving problems for the real world 一些面向对象的设计法则 重构、分支语句、虚函数、抽象函数与多态--《重构:改善既有代码设计》之读书心得 为内嵌类(Nested Class)配置NHibernate的O/R Mapping文件
NHibernate 执行内嵌类(Nested Class)查询
mahope · 2005-05-21 · via 博客园 - mahope

为了使用NHibernate执行内嵌类查询,我修改了NHibernate的源代码,增加了两个语句。

/*SessionFactoryImpl.cs*/
/// 
<summary>
        /// 
        /// 
</summary>
        /// 
<param name="clazz"></param>
        /// 
<returns></returns>
        public string[ ] GetImplementors( System.Type clazz )
        {
            ArrayList results = new ArrayList();
            foreach( IClassPersister p in classPersisters.Values )
            {
                if( p is IQueryable )
                {
                    IQueryable q = ( IQueryable ) p;
                    string name = q.ClassName;

                    if(name.IndexOf("+")!=-1)
                        name = name.Replace("+","..");

                    bool isMappedClass = clazz.Equals( q.MappedClass );
                    if( q.IsExplicitPolymorphism )
                    {
                        if( isMappedClass )
                        {
                            return new string[ ] {name};
                        }
                    }
                    else
                    {
                        if( isMappedClass )
                        {
                            results.Add( name );
                        }
                        else if(
                            clazz.IsAssignableFrom( q.MappedClass ) &&
                                ( !q.IsInherited || !clazz.IsAssignableFrom( q.MappedSuperclass ) ) )
                        {
                            results.Add( name );
                        }
                    }
                }
            }
            return ( string[ ] ) results.ToArray( typeof( string ) );
        }

        /// 
<summary>
        /// 
        /// 
</summary>
        /// 
<param name="name"></param>
        /// 
<returns></returns>
        public string GetImportedClassName( string name )
        {
            // UPDATE_NOTES:resolve nested class problem
            if(name.IndexOf("..")!=-1)
                name = name.Replace("..","+");

            string result = imports[ name ] as string;
            return ( result == null ) ? name : result;
        }

现在可以在表达式中用 ParentClass..NestedCalss语法来执行查询了。