Exemplo n.º 1
0
        public ProviderFullInformation[] GetProvider(long clientId)
        {
            using (var db = GetDBConnect())
            {
                var providers = Enumerable.ToArray(Queryable.Select(Queryable.Where(db.signal_providers, x => x.client_account_id == clientId), x => new ProviderFullInformation
                {
                    AccountId   = x.id,
                    AccountType = (AccountType)x.account_type_id,
                    Avatar      = x.avatar,
                    ClientId    = x.client_account_id,
                    Currency    = x.currency,
                    IsVisible   = x.isvisible,
                    Login       = x.login,
                    Nickname    = x.nickname,
                    RatingValue = x.rating_value == null ? 0.0f : x.rating_value.Value,
                }));

                foreach (var provider in providers)
                {
                    provider.Subscribers = Enumerable.ToList <SubscriberData>((from subscriber in db.signal_subscribers
                                                                               join subscription in db.signal_subscriptions on subscriber.id equals subscription.account_slave_id
                                                                               where subscription.account_master_id == provider.AccountId
                                                                               select new SubscriberData
                    {
                        AccountId = subscriber.id,
                        Avatar = subscriber.avatar,
                        ClientId = subscriber.client_account_id,
                        Nickname = subscriber.nickname
                    }));
                }

                return(providers);
            }
        }
Exemplo n.º 2
0
 public static IAsyncQueryable <TResult> Select <TSource, TResult>(this IAsyncQueryable <TSource> source, Expression <Func <TSource, TResult> > selector)
 {
     return((IAsyncQueryable <TResult>)Queryable.Select(source, selector));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 动态映射字段
 /// </summary>
 /// <typeparam name="TSource">源</typeparam>
 /// <typeparam name="TTarget">目标源</typeparam>
 /// <param name="query"></param>
 /// <returns></returns>
 public static IQueryable <TTarget> Select <TSource, TTarget>(this IQueryable <TSource> query)
 {
     return(Queryable.Select(query, GetLamda <TSource, TTarget>()));
 }
Exemplo n.º 4
0
 public virtual IQueryable <TResult> Select <TSource, TResult>(IQueryable <TSource> source, Expression <Func <TSource, Int32, TResult> > selector)
 {
     return(Queryable.Select <TSource, TResult>(source, selector));
 }
Exemplo n.º 5
0
 /// <summary>
 /// 动态映射字段
 /// </summary>
 /// <typeparam name="TTarget">目标源</typeparam>
 /// <param name="query"></param>
 /// <returns></returns>
 public static IQueryable <TTarget> Select <TTarget>(this IQueryable <object> query)
 {
     return(Queryable.Select(query, GetLamda <object, TTarget>(query.GetType().GetGenericArguments()[0])));
 }