MongoDB学习笔记~以匿名对象做为查询参数,方便查询子对象

回到目录

对于MongoDB的封装还在继续,对于不断追求简单的编程还在继续,对于喜欢代码的那么感觉,还在继续...

当你的mongo数据表里有子对象时,尤其是列表对象时,使用官方的驱动很是不爽,要记得很多新的对象类型,麻烦,所以,将它进行封装,让GetModel支持匿名参数!

表结构可能是这样

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdAAAAGyCAIAAADbAwIGAAAgAElEQVR4nO2dW5asIAxFe1wOyPE4GidTg7E/fCWQIFiKj9r7466+aCGgdSpGOP4NAABQhb+rGwAA8CsguAAAlUBwAQAqIQT30zV/f033ua4xAABvZhXcT9egtgAA54HgAgBUAsEFAKjEJLh9+/fXdNc2BQDg3RDhAgBUAsEFAKgEggsAUAnm4QIAVIKVZgAAlUBwAQAqgeACAFQCwQUAqASCCwBQCQQXAKASCC4AQCV2CW7f/v39/bX9p2v+sqfu9m1iz779E2YOu+ovwKt//P9E2y/7l5bnHN7eXY+DVT795QzJ0iBjj7HXuqlWme5ZnsOGV4/XnnH/uJFePTb7xt89hnFevHba9Zx93cLz2SW4yxKJhHQU07fLd/uU+gVe/Z+uMQ9WWp6ka/7aLvFBMQ5OubckUPyk9a0et0/XxAP56RqpFctm6WSUs/4wUY/Znmn/vg1q9upJHbhw/M1xGInPi9dOt56zr1t4PvsFt+3nr+bWD/kSiIS7igil7UPBza9/GIY1uvim/ccJ7hr9NJ2UrEmDgg8mxyEu75qm61OxbNi0T9dYIi738YQ1KDf7lVlPOFSW4Hr12ONZOv7OOAzeeXHa6daz57qF32JfDneOXWRMskX0VZQ5huBWekf9JYLr1X9QSkGGc3K99Ho09cX2xsEdH3XDag+RDpP7tmlbS6BXXYpSB/MmUe71K1mP1Z617BMWWfW4xy0cf28cnPPitzM1nsXfC/gp6j00CwU3uI796OMavHva7XIvJyDlRHxTvXHwxyf4NocqEd3uqpSiHOe+FRFlu52m8E5Quh7vNt4SMqse/7hBQ7fG3xsH+7z47XTHE2ALB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W9/IOVHs4Z+dt2VW9ZaxuHv395F7fka/l75GxX+3/7/NHtNqiDROsERY9wIAFR/r5LV6VLdYXh3DMB1L3yh9uXuVZa66CeGO95SO10iTyy2i/I363Sl1ZrW+TW5FZrmxt74XBD8kxYROs8N3Vdrf4sQeQX5R/43Q0uJs5U+4fKL9XAh8tfpfz+075Ob8v//mvvgQSiL6JS48Kl86Gy02wexIzV/vbGhQnLoM4neSuRX7jihRkSDAX547ZAs6a2RtvC2lxbre2Fqza4zV/6tSsnw1pj9eXJ8o/RffX9y7vatOBvwd743R+aar/g+TXyVx0E3ZIlOqh8IGs733u73dv0q5y7dMG3cO1Vvjkr1gduZ5xhm/dtGVRq4n28mTa/cMXD4rsfUX5Xva8Xt+Nc+3a+6w688F1cJ3/0BTcdfiZvKviC/K2+wQeVA19/6dalRXvrLrd3n781gTrYvO6cu0p+V6WP+wWk6r10INutc4eXqB0VW5eur/80TL+pw29QVmxXz5qdDNo8/klThUWXfOpS38QVpdSMDKn2z/rj/1rbUwsg6vO3qxtBNEJWHCEny82LdYz+ieXvnHNQjZ6LNY+imJHvX9616/Orkv/RWXGcnNwb9VeRZePhvUstrCgAruLTh5/jmO9YjfxLzooRZW7WcJp9cGMPQKIgP0CiID9AoiA/QKIgP0CiID9AoiA/QKIgP0CiID9AoiA/QKIgP0CiID9AoiA/QKIgP0CiID9AoiA/QKL8P6EgO5Xxh6arAAAAAElFTkSuQmCC" alt="" />

看了上面的语句感觉挺酷吧,呵呵,下面看一下实现的代码,今天下午写的,呵呵!

  public IEnumerable<TEntity> GetModel<U>(U template)
{
return _table.Find(GeneratorMongoQuery(template)).ToListAsync().Result;
} public PagedResult<TEntity> GetModel<U>(int pageIndex, int pageSize)
{
return this.GetModel(new { }, pageIndex, pageSize); } public PagedResult<TEntity> GetModel<U>(U template, int pageIndex, int pageSize)
{
return this.GetModel(template, new { }, pageIndex, pageSize);
} public PagedResult<TEntity> GetModel<U, O>(U template, O orderby, int pageIndex, int pageSize)
{
#region 条件过滤
BsonDocumentFilterDefinition<TEntity> filterDefinition = GeneratorMongoQuery(template);
#endregion #region 排序处理
SortDefinition<TEntity> sorts = new ObjectSortDefinition<TEntity>(new { });
foreach (var item in typeof(O).GetProperties())
{
if ((OrderType)item.GetValue(orderby) == OrderType.Asc)
sorts = sorts.Ascending(item.Name);
else
sorts = sorts.Descending(item.Name);
}
#endregion #region 分页处理
var skip = (pageIndex - ) * pageSize; var recordCount = _table.Find(filterDefinition).CountAsync(new CancellationToken()).Result;
var limit = pageSize;
return new PagedResult<TEntity>(
recordCount,
(int)(recordCount + pageSize - ) / pageSize,
pageSize,
pageIndex,
_table.Find(filterDefinition)
.Sort(sorts)
.Skip(skip)
.Limit(limit)
.ToListAsync().Result);
#endregion }

提出了一个条件过滤的私有方法,因为它的逻辑在两个方法里都用了,所以进行提取

   /// <summary>
/// 构建Mongo的查询表达式,通过一个匿名对象
/// </summary>
/// <typeparam name="U"></typeparam>
/// <param name="template"></param>
/// <returns></returns>
private BsonDocumentFilterDefinition<TEntity> GeneratorMongoQuery<U>(U template)
{
var qType = typeof(U);
var outter = new BsonDocument();
var simpleQuery = new BsonDocument();
foreach (var item in qType.GetProperties())
{
if (item.PropertyType.IsClass && item.PropertyType != typeof(string))
{
//复杂类型,导航属性,类对象和集合对象
foreach (var sub in item.PropertyType.GetProperties())
{
simpleQuery.Add(new BsonElement(item.Name + "." + sub.Name,
BsonValue.Create(sub.GetValue(item.GetValue(template)))
));
}
}
else
{
//简单类型,ValueType和string
simpleQuery.Add(new BsonElement(item.Name,
BsonValue.Create(item.GetValue(template))
));
}
}
return new BsonDocumentFilterDefinition<TEntity>(simpleQuery);
}

结果就是我们想好的,怎么样,用法挺友好吧

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOgAAAA+CAIAAACurMAdAAAHVklEQVR4nO2bW2xURRiAzyuFggJSUW4ttOVS5SJeoEXBBzUagsVUFC/RRBJpaYFCsbSl0FKh3ARFxKARgmAgRKLRmJi0Sd/k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womHDtPzXlfaGcVNLSm6j9vGkPxQDnmHpdduGfY4q8B17WaC4oZJmj+AsMNBUNd8Kuq61kJrQ0ZRcZG7HRQXURIUF1ESFBdREhQXURIUF1ESFBdREhQXURIUF1ESFBdREhQXURIUF1ES8T8gREZ6jggigOIiSoLiIkqC4iJKghdniJKguIiSoLiIkqC4iJKguIiSoLiIkqC4iJKguIiSoLiIkqC4iIr8B07NZB5phvzNAAAAAElFTkSuQmCC" alt="" />

回到目录

上一篇:awk中的冒泡排序


下一篇:分布式架构真正适用于大型互联网项目的架构! dubbo+zookeeper+springmvc+mybatis+shiro+redis