예제 #1
0
    /// <summary>
    /// 【linq to sql】专用扩展方法,不建议直接使用
    /// </summary>
    public static ISelect <TReturn> Select <T1, TReturn>(this ISelect <T1> that, Expression <Func <T1, TReturn> > select) where T1 : class where TReturn : class
    {
        var s1p = that as Select1Provider <T1>;

        if (typeof(TReturn) == typeof(T1))
        {
            return(that as ISelect <TReturn>);
        }
        s1p._tables[0].Parameter = select.Parameters[0];
        s1p._selectExpression    = select.Body;
        if (s1p._orm.CodeFirst.IsAutoSyncStructure)
        {
            (s1p._orm.CodeFirst as CodeFirstProvider)._dicSycedTryAdd(typeof(TReturn)); //._dicSyced.TryAdd(typeof(TReturn), true);
        }
        var ret = s1p._orm.Select <TReturn>() as Select1Provider <TReturn>;

        Select0Provider.CopyData(s1p, ret, null);
        return(ret);
    }
예제 #2
0
    /// <summary>
    /// 【linq to sql】专用扩展方法,不建议直接使用
    /// </summary>
    public static ISelect <TResult> Join <T1, TInner, TKey, TResult>(this ISelect <T1> that, ISelect <TInner> inner, Expression <Func <T1, TKey> > outerKeySelector, Expression <Func <TInner, TKey> > innerKeySelector, Expression <Func <T1, TInner, TResult> > resultSelector) where T1 : class where TInner : class where TResult : class
    {
        var s1p = that as Select1Provider <T1>;

        InternalJoin2(s1p, outerKeySelector, innerKeySelector, resultSelector);
        if (typeof(TResult) == typeof(T1))
        {
            return(that as ISelect <TResult>);
        }
        s1p._selectExpression = resultSelector.Body;
        if (s1p._orm.CodeFirst.IsAutoSyncStructure)
        {
            (s1p._orm.CodeFirst as CodeFirstProvider)._dicSycedTryAdd(typeof(TResult)); //._dicSyced.TryAdd(typeof(TResult), true);
        }
        var ret = s1p._orm.Select <TResult>() as Select1Provider <TResult>;

        Select0Provider.CopyData(s1p, ret, null);
        return(ret);
    }
예제 #3
0
    /// <summary>
    /// 【linq to sql】专用扩展方法,不建议直接使用
    /// </summary>
    public static ISelect <TResult> SelectMany <T1, TCollection, TResult>(this ISelect <T1> that, Expression <Func <T1, ISelect <TCollection> > > collectionSelector, Expression <Func <T1, TCollection, TResult> > resultSelector) where T1 : class where TCollection : class where TResult : class
    {
        var s1p = that as Select1Provider <T1>;

        InternalSelectMany2(s1p, collectionSelector, resultSelector);
        if (typeof(TResult) == typeof(T1))
        {
            return(that as ISelect <TResult>);
        }
        s1p._selectExpression = resultSelector.Body;
        if (s1p._orm.CodeFirst.IsAutoSyncStructure)
        {
            (s1p._orm.CodeFirst as CodeFirstProvider)._dicSycedTryAdd(typeof(TResult)); //._dicSyced.TryAdd(typeof(TResult), true);
        }
        var ret = s1p._orm.Select <TResult>() as Select1Provider <TResult>;

        Select0Provider.CopyData(s1p, ret, null);
        return(ret);
    }