DbContext 生命周期和使用规范

源代码

3.3.1. 工作单元

IUnitOfWorkManager 和 UnitOfWorkManager

using Microsoft.EntityFrameworkCore;

using System;

using System.Collections.Generic;

using System.Text;

namespace EntityFramework.UnitOfWorks

{

    public interface IUnitOfWorkManager

    {

        IUnitOfWorkHandle<TDbContext> Begin<TDbContext>() where TDbContext : DbContext;

        IUnitOfWorkHandle<TDbContext> BeginNew<TDbContext>() where TDbContext : DbContext;

    }

}

using Microsoft.EntityFrameworkCore;

using Microsoft.Extensions.DependencyInjection;

using System;

using System.Collections.Generic;

using System.Text;

using System.Threading;

namespace EntityFramework.UnitOfWorks.Impl

{

    public class UnitOfWorkManager : IUnitOfWorkManager

    {

        private readonly IServiceProvider _serviceProvider;

        public UnitOfWorkManager(IServiceProvider serviceProvider)

        {

            _serviceProvider = serviceProvider;

        }

        public IUnitOfWorkHandle<TDbContext> Begin<TDbContext>() where TDbContext : DbContext

        {

            var uowHander = AsyncLocalCurrentUnitOfWorkHandleProvider<TDbContext>.Current;

            if (uowHander == null)

            {

                return BeginNew<TDbContext>();

            }

            else

            {

                return new InnerUnitOfWorkHandle<TDbContext>();

            }

        }

        public IUnitOfWorkHandle<TDbContext> BeginNew<TDbContext>() where TDbContext : DbContext

        {

            IServiceScope serviceScope = _serviceProvider.CreateScope();

            var uowHander = new UnitOfWorkHandle<TDbContext>(serviceScope);

            AsyncLocalCurrentUnitOfWorkHandleProvider<TDbContext>.Current = uowHander;

            return uowHander;

        }

    }

}

IUnitOfWorkHandle<TDbContext>, UnitOfWorkHandle<TDbContext> 和 InnerUnitOfWorkHandle<TDbContext>

using Microsoft.EntityFrameworkCore;

using System;

using System.Collections.Generic;

using System.Text;

using System.Threading.Tasks;

namespace EntityFramework.UnitOfWorks

{

    public interface IUnitOfWorkHandle<TDbContext> : IDisposable where TDbContext:DbContext

    {

        TDbContext GetActiveUnitOfWork();

        int SaveChange();

        Task<int> SaveChangeAsync();

        bool IsDisposed { get; }

    }

}

using Microsoft.EntityFrameworkCore;

using Microsoft.Extensions.DependencyInjection;

using System;

using System.Collections.Generic;

using System.Text;

using System.Threading;

using System.Threading.Tasks;

namespace EntityFramework.UnitOfWorks.Impl

{

    public class UnitOfWorkHandle<TDbContext> : IUnitOfWorkHandle<TDbContext> where TDbContext : DbContext

    {

        private readonly IServiceScope _serviceScope;

        public bool IsDisposed { get; private set; }

        public UnitOfWorkHandle(IServiceScope serviceScope)

        {

            _serviceScope = serviceScope;

        }

        public TDbContext GetActiveUnitOfWork()

        {

            return _serviceScope.ServiceProvider.GetRequiredService<TDbContext>();

        }

        public void Dispose()

        {

            _serviceScope.Dispose();

            IsDisposed = true;

            // 清空当前 Handle 或回到 OuterHandle

            AsyncLocalCurrentUnitOfWorkHandleProvider<TDbContext>.Current = null;

        }

        public int SaveChange()

        {

            var dbContext = GetActiveUnitOfWork();

            if (dbContext == null)

            {

                return 0;

            }

            return dbContext.SaveChanges();

        }

        public async Task<int> SaveChangeAsync()

        {

            var dbContext = GetActiveUnitOfWork();

            if (dbContext == null)

            {

                return await Task.FromResult(0);

            }

            return await dbContext.SaveChangesAsync(CancellationToken.None);

        }

    }

}

using Microsoft.EntityFrameworkCore;

using System;

using System.Collections.Generic;

using System.Text;

using System.Threading.Tasks;

namespace Nuctech.TrDevice.EntityFramework.UnitOfWorks.Impl

{

    public class InnerUnitOfWorkHandle<TDbContext> : IUnitOfWorkHandle<TDbContext> where TDbContext : DbContext

    {

        public bool IsDisposed { get; private set; }

        public void Dispose()

        {

            IsDisposed = true;

        }

        public TDbContext GetActiveUnitOfWork()

            => AsyncLocalCurrentUnitOfWorkHandleProvider<TDbContext>.Current?.GetActiveUnitOfWork();

        public int SaveChange()

        {

            return 0;

        }

        public Task<int> SaveChangeAsync()

        {

            return Task.FromResult(0);

        }

    }

}

AsyncLocalCurrentUnitOfWorkHandleProvider<TDbContext> 和 LocalUowWrapper<TDbContext>

由于这两个类是强关联的,所以这里将LocalUowWrapper<TDbContext> 定义为其内部类 LocalUowWrapper

using Microsoft.EntityFrameworkCore;

using System;

using System.Collections.Generic;

using System.Text;

using System.Threading;

namespace EntityFramework.UnitOfWorks.Impl

{

    public class AsyncLocalCurrentUnitOfWorkHandleProvider<TDbContext> where TDbContext : DbContext

    {

        private static readonly AsyncLocal<LocalUowWrapper> AsyncLocalUow = new AsyncLocal<LocalUowWrapper>();

        public static UnitOfWorkHandle<TDbContext> Current

        {

            get { return GetCurrentUow(); }

            set { SetCurrentUow(value); }

        }

        private static UnitOfWorkHandle<TDbContext> GetCurrentUow()

        {

            var uow = AsyncLocalUow.Value?.UnitOfWorkHandle;

            if (uow == null)

            {

                return null;

            }

            if (uow.IsDisposed)

            {

                AsyncLocalUow.Value = null;

                return null;

            }

            return uow;

        }

        private static void SetCurrentUow(UnitOfWorkHandle<TDbContext> value)

        {

            lock (AsyncLocalUow)

            {

                if (value == null)

                {

                    if (AsyncLocalUow.Value == null)

                    {

                        return;

                    }

                    if (AsyncLocalUow.Value.Outer == null)

                    {

                        AsyncLocalUow.Value.UnitOfWorkHandle = null;

                        AsyncLocalUow.Value = null;

                        return;

                    }

                    var oldValue = AsyncLocalUow.Value;

                    AsyncLocalUow.Value = AsyncLocalUow.Value.Outer;

                    oldValue.Outer = null;

                }

                else

                {

                    if (AsyncLocalUow.Value?.UnitOfWorkHandle == null)

                    {

                        if (AsyncLocalUow.Value != null)

                        {

                            AsyncLocalUow.Value.UnitOfWorkHandle = value;

                        }

                        AsyncLocalUow.Value = new LocalUowWrapper(value);

                        return;

                    }

                    var newValue = new LocalUowWrapper(value) { Outer = AsyncLocalUow.Value };

                    AsyncLocalUow.Value = newValue;

                }

            }

        }

        private class LocalUowWrapper

        {

            public UnitOfWorkHandle<TDbContext> UnitOfWorkHandle { get; set; }

            public LocalUowWrapper Outer { get; set; }

            public LocalUowWrapper(UnitOfWorkHandle<TDbContext> unitOfWorkHandle)

            {

                UnitOfWorkHandle = unitOfWorkHandle;

            }

        }

    }

}

3.3.2. 单元测试

以下单元测试基本涵盖了常见的工作单元使用情况;

事务时直接使用 DbContext 启动的事务,更复杂的情况请查看官方文档;

using Microsoft.EntityFrameworkCore;

using Microsoft.EntityFrameworkCore.Storage;

using Microsoft.Extensions.DependencyInjection;

using EntityFramework.UnitOfWorks;

using EntityFramework.UnitOfWorks.Impl;

using Shouldly;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Threading.Tasks;

using Xunit;

namespace EntityFramework.UnitOfWorkTest

{

        public class UnitOfWorkTests

    {

        public const string ConnectString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=TestDatabase";

        private readonly IServiceProvider _serviceProvider;

        private readonly IUnitOfWorkManager _unitOfWorkManager;

        public UnitOfWorkTests()

        {

            IServiceCollection services = new ServiceCollection();

            services.AddDbContext<PersionDbContext>(options => options.UseSqlServer(ConnectString));

            services.AddTransient<IUnitOfWorkManager, UnitOfWorkManager>();

            _serviceProvider = services.BuildServiceProvider();

            _unitOfWorkManager = _serviceProvider.GetRequiredService<IUnitOfWorkManager>();

        }

        /// <summary>

        /// 正常操作

        /// </summary>

        /// <returns></returns>

        [Fact]

        public async Task ShouldNormalOperation()

        {

            using (var uowHandle = _unitOfWorkManager.Begin<PersionDbContext>())

            {

                var lists = uowHandle.GetActiveUnitOfWork().Persions.ToList();

                //清理

                lists.ForEach(u => uowHandle.GetActiveUnitOfWork().Persions.Remove(u));

                uowHandle.SaveChange();

            }

            await AddUser("张三");

            await AddUser("李四");

            await AddUser("王五");

            using (var uowHandle = _unitOfWorkManager.Begin<PersionDbContext>())

            {

                var lists = uowHandle.GetActiveUnitOfWork().Persions.ToList();

                lists.Count.ShouldBe(3);

                //清理

                lists.ForEach(u => uowHandle.GetActiveUnitOfWork().Persions.Remove(u));

                uowHandle.SaveChange();

            }

            async Task AddUser(string name)

            {

                using (var uowHandle = _unitOfWorkManager.Begin<PersionDbContext>())

                {

                    uowHandle.GetActiveUnitOfWork().Persions.Add(new Persion() { Name = name });

                    await uowHandle.SaveChangeAsync();

                }

            }

        }

        /// <summary>

        /// 超出使用范围使用工作单元

        /// </summary>

        [Fact]

        public void ShouldNotUseUow()

        {

            var uowHandle = _unitOfWorkManager.Begin<PersionDbContext>();

            uowHandle.Dispose();

            Assert.Throws<ObjectDisposedException>(() => uowHandle.GetActiveUnitOfWork().Persions.ToList());

        }

        /// <summary>

        /// 工作单元嵌套时,当前工作单IUnitOfWorkHandle和DbContext的实际情况

        /// </summary>

        [Fact]

        public void ShouldAcrossMutiFunction()

        {

            using (var uowHandle = _unitOfWorkManager.Begin<PersionDbContext>())

            {

                var outerDbContext = uowHandle.GetActiveUnitOfWork();

                uowHandle.ShouldBeOfType<UnitOfWorkHandle<PersionDbContext>>();

                using (var innerUowHandle = _unitOfWorkManager.BeginNew<PersionDbContext>())

                {

                    var innerDbContext = innerUowHandle.GetActiveUnitOfWork();

                    innerUowHandle.GetActiveUnitOfWork().ShouldNotBe(outerDbContext);

                    innerUowHandle.ShouldBeOfType<UnitOfWorkHandle<PersionDbContext>>();

                    innerUowHandle.ShouldNotBe(uowHandle);

                    using (var innerInnerUowHandle = _unitOfWorkManager.BeginNew<PersionDbContext>())

                    {

                        innerInnerUowHandle.ShouldBeOfType<UnitOfWorkHandle<PersionDbContext>>();

                        innerInnerUowHandle.GetActiveUnitOfWork().ShouldNotBe(outerDbContext);

                        innerInnerUowHandle.ShouldNotBe(uowHandle);

                    }

                    innerUowHandle.GetActiveUnitOfWork().ShouldBe(innerDbContext);

                }

                using (var innerUowHandle = _unitOfWorkManager.Begin<PersionDbContext>())

                {

                    innerUowHandle.ShouldBeOfType<InnerUnitOfWorkHandle<PersionDbContext>>();

                    innerUowHandle.GetActiveUnitOfWork().ShouldBe(outerDbContext);

                }

                uowHandle.GetActiveUnitOfWork().ShouldBe(outerDbContext);

            }

        }

        /// <summary>

        /// 使用数据库事务

        /// </summary>

        /// <param name="isCommit">是否提交数据</param>

        /// <returns></returns>

        [Theory]

        [InlineData(true)]

        [InlineData(false)]

        public async Task ShouldCommitTransaction(bool isCommit)

        {

            using (var uowHandle = _unitOfWorkManager.Begin<PersionDbContext>())

            {

                var lists = uowHandle.GetActiveUnitOfWork().Persions.ToList();

                lists.ForEach(u => uowHandle.GetActiveUnitOfWork().Persions.Remove(u));

                uowHandle.SaveChange();

            }

            List<string> names = new List<string> { "张三", "李四", "王老五" };

            using (var uowHandle = _unitOfWorkManager.Begin<PersionDbContext>())

            {

                using (var transaction = uowHandle.GetActiveUnitOfWork().Database.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))

                {

                    for (int i = 0; i < names.Count; i++)

                    {

                        uowHandle.GetActiveUnitOfWork().Persions.Add(new Persion() { Name = names[i] });

                        //事务期间的SaveChange不会提交到数据库

                        await uowHandle.SaveChangeAsync();

                    }

                    if (isCommit)

                    {

                        transaction.Commit();

                    }

                    else

                    {

                        transaction.Rollback();

                    }

                }

            }

            using (var uowHandle = _unitOfWorkManager.Begin<PersionDbContext>())

            {

                uowHandle.GetActiveUnitOfWork().Persions.Count().ShouldBe(isCommit ? 3 : 0);

            }

        }

    }

}

4. 封装-仓储

4.1. 分析

关于仓储类的封装主要是为了更方便的使用工作单元;

面向我们经常使用的操作: Select, Insert, Update, Delete 四个方向进行封装。

4.2. 设计

4.2.1. 类图

IRepository<TDbContext, TEntity>

+IUnitOfWorkManager UnitOfWorkManager+TDbContext CurrentDbContext

+BeginUnitOfWork() : IUnitOfWorkHandle<TDbContext>+BeginNewUnitOfWork() : IUnitOfWorkHandle<TDbContext>+Insert(TEntity entity) : TEntity+GetAll() : IQueryable<TEntity>+GetAllList() : List<TEntity>+Update(TEntity entity) : TEntity+Delete(TEntity entity)

EFRepository<TDbContext, TEntity>

AsyncLocalCurrentUnitOfWorkHandleProvider<TDbContext>

IUnitOfWorkManager

IUnitOfWorkHandle

4.2.2. 时序图

EFRepository

AsyncLocalCurrentUnitOfWorkHandleProvider

IUnitOfWorkManager

IUnitOfWorkHandle

比如返回IQueryable的方法

获取当前生效的 DbContext

使用此上下文执行操作

抛出 ArgumentNullException 异常

alt

[存在]

[不存在]

Begin()一个工作单元

创建的工作单元处理器类型受外部影响,前面已介绍

Begin()一个工作单元

获取生效的DbContext并进行操作

释放资源: Dispose

par

[执行后需要DbContext继续生效的方法]

[执行后DbContext不生效也没影响的方法]

EFRepository

AsyncLocalCurrentUnitOfWorkHandleProvider

IUnitOfWorkManager

IUnitOfWorkHandle

4.2.3. 源码

IRepository<TDbContext, TEntity>

using Microsoft.EntityFrameworkCore;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Linq.Expressions;

using System.Threading.Tasks;

using EntityFramework.UnitOfWorks;

namespace EntityFramework.Repositories

    public interface IRepository<TDbContext, TEntity> where TEntity : class where TDbContext : DbContext

    {

        IUnitOfWorkManager UnitOfWorkManager { get; }

        TDbContext CurrentDbContext { get; }

        IUnitOfWorkHandle<TDbContext> BeginUnitOfWork();

        IUnitOfWorkHandle<TDbContext> BeginNewUnitOfWork();

        #region Select/Get/Query

        IQueryable<TEntity> GetAll();

        IQueryable<TEntity> GetAllIncluding(params Expression<Func<TEntity, object>>[] propertySelectors);

        List<TEntity> GetAllList();

        Task<List<TEntity>> GetAllListAsync();

        List<TEntity> GetAllList(Expression<Func<TEntity, bool>> predicate);

        Task<List<TEntity>> GetAllListAsync(Expression<Func<TEntity, bool>> predicate);

        T Query<T>(Func<IQueryable<TEntity>, T> queryMethod);

        TEntity Single(Expression<Func<TEntity, bool>> predicate);

        Task<TEntity> SingleAsync(Expression<Func<TEntity, bool>> predicate);

        TEntity FirstOrDefault(Expression<Func<TEntity, bool>> predicate);

        Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate);

        #endregion

        TEntity Insert(TEntity entity);

        Task<TEntity> InsertAsync(TEntity entity);

        TEntity Update(TEntity entity);

        Task<TEntity> UpdateAsync(TEntity entity);

        void Delete(TEntity entity);

        Task DeleteAsync(TEntity entity);

    }

}

EFRepository<TDbContext, TEntity>

using Microsoft.EntityFrameworkCore;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Linq.Expressions;

using System.Threading.Tasks;

using EntityFramework.UnitOfWorks;

using EntityFramework.UnitOfWorks.Impl;

namespace EntityFramework.Repositories.Impl

{

    public class EFRepository<TDbContext, TEntity> : IRepository<TDbContext, TEntity> where TEntity : class where TDbContext : DbContext

    {

        private readonly IUnitOfWorkManager _unitOfWorkManager;

        public EFRepository(IUnitOfWorkManager unitOfWorkManager)

        {

            _unitOfWorkManager = unitOfWorkManager;

        }

        public virtual TDbContext CurrentDbContext => AsyncLocalCurrentUnitOfWorkHandleProvider<TDbContext>.Current?.GetActiveUnitOfWork();

        public IUnitOfWorkManager UnitOfWorkManager => _unitOfWorkManager;

        public IUnitOfWorkHandle<TDbContext> BeginUnitOfWork()

        {

            return _unitOfWorkManager.Begin<TDbContext>();

        }

        public IUnitOfWorkHandle<TDbContext> BeginNewUnitOfWork()

        {

            return _unitOfWorkManager.BeginNew<TDbContext>();

        }

        public TEntity FirstOrDefault(Expression<Func<TEntity, bool>> predicate)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            return uowHander.GetActiveUnitOfWork().Set<TEntity>().FirstOrDefault(predicate);

        }

        public async Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            return await uowHander.GetActiveUnitOfWork().Set<TEntity>().FirstOrDefaultAsync(predicate);

        }

        public IQueryable<TEntity> GetAll()

        {

            var context = CurrentDbContext;

            if (context != null)

            {

                return context.Set<TEntity>().AsQueryable();

            }

            throw new ArgumentNullException(nameof(CurrentDbContext));

        }

        public IQueryable<TEntity> GetAllIncluding(params Expression<Func<TEntity, object>>[] propertySelectors)

        {

            var context = CurrentDbContext;

            if (context != null)

            {

                var query = context.Set<TEntity>().AsQueryable();

                if (propertySelectors != null)

                {

                    foreach (var propertySelector in propertySelectors)

                    {

                        query = query.Include(propertySelector);

                    }

                }

                return query;

            }

            throw new ArgumentNullException(nameof(CurrentDbContext));

        }

        public List<TEntity> GetAllList()

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            return uowHander.GetActiveUnitOfWork().Set<TEntity>().ToList();

        }

        public List<TEntity> GetAllList(Expression<Func<TEntity, bool>> predicate)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            return uowHander.GetActiveUnitOfWork().Set<TEntity>().Where(predicate).ToList();

        }

        public async Task<List<TEntity>> GetAllListAsync()

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            return await uowHander.GetActiveUnitOfWork().Set<TEntity>().ToListAsync();

        }

        public async Task<List<TEntity>> GetAllListAsync(Expression<Func<TEntity, bool>> predicate)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            return await uowHander.GetActiveUnitOfWork().Set<TEntity>().Where(predicate).ToListAsync();

        }

        public T Query<T>(Func<IQueryable<TEntity>, T> queryMethod)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            return queryMethod(GetAll());

        }

        public TEntity Single(Expression<Func<TEntity, bool>> predicate)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            return uowHander.GetActiveUnitOfWork().Set<TEntity>().SingleOrDefault(predicate);

        }

        public async Task<TEntity> SingleAsync(Expression<Func<TEntity, bool>> predicate)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            return await uowHander.GetActiveUnitOfWork().Set<TEntity>().SingleOrDefaultAsync(predicate);

        }

        public TEntity Insert(TEntity entity)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            entity = uowHander.GetActiveUnitOfWork().Set<TEntity>().Add(entity).Entity;

            uowHander.SaveChange();

            return entity;

        }

        public async Task<TEntity> InsertAsync(TEntity entity)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            entity = uowHander.GetActiveUnitOfWork().Set<TEntity>().Add(entity).Entity;

            await uowHander.SaveChangeAsync();

            return entity;

        }

        public TEntity Update(TEntity entity)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            var context = uowHander.GetActiveUnitOfWork();

            AttachIfNot(context, entity);

            context.Entry(entity).State = EntityState.Modified;

            uowHander.SaveChange();

            return entity;

        }

        public async Task<TEntity> UpdateAsync(TEntity entity)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            var context = uowHander.GetActiveUnitOfWork();

            AttachIfNot(context, entity);

            context.Entry(entity).State = EntityState.Modified;

            await uowHander.SaveChangeAsync();

            return entity;

        }

        public void Delete(TEntity entity)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            var context = uowHander.GetActiveUnitOfWork();

            AttachIfNot(context, entity);

            context.Set<TEntity>().Remove(entity);

            uowHander.SaveChange();

        }

        public async Task DeleteAsync(TEntity entity)

        {

            using var uowHander = _unitOfWorkManager.Begin<TDbContext>();

            var context = uowHander.GetActiveUnitOfWork();

            AttachIfNot(context, entity);

            context.Set<TEntity>().Remove(entity);

            await uowHander.SaveChangeAsync();

        }

        protected virtual void AttachIfNot(DbContext dbContext, TEntity entity)

        {

            var entry = dbContext.ChangeTracker.Entries().FirstOrDefault(ent => ent.Entity == entity);

            if (entry != null)

            {

                return;

            }

            dbContext.Set<TEntity>().Attach(entity);

        }

    }

}

USB Microphone https://www.soft-voice.com/

Wooden Speakers  https://www.zeshuiplatform.com/

亚马逊测评 www.yisuping.cn

深圳网站建设www.sz886.com

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,734评论 6 505
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,931评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,133评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,532评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,585评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,462评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,262评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,153评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,587评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,792评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,919评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,635评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,237评论 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,855评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,983评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,048评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,864评论 2 354

推荐阅读更多精彩内容