我正致力于在班克建立推广方法。 共同市场动态项目。 但出于某种原因,它不会运行。 签名似乎相符。
public static IQueryable GroupJoin(this IQueryable outer, IEnumerable inner, string outerSelector, string innerSelector, string resultsSelector, params object[] values)
{
if (inner == null) throw new ArgumentNullException("inner");
if (outerSelector == null) throw new ArgumentNullException("outerSelector");
if (innerSelector == null) throw new ArgumentNullException("innerSelector");
if (resultsSelector == null) throw new ArgumentNullException("resultsSelctor");
LambdaExpression outerSelectorLambda = DynamicExpression.ParseLambda(outer.ElementType, null, outerSelector, values);
Type enumType = GetList(inner.AsQueryable().ElementType).GetType();
LambdaExpression innerSelectorLambda = DynamicExpression.ParseLambda(inner.AsQueryable().ElementType, null, innerSelector, values);
ParameterExpression[] parameters = new ParameterExpression[] {
Expression.Parameter(outer.ElementType, "outer"), Expression.Parameter(enumType, "inner") };
LambdaExpression resultsSelectorLambda = DynamicExpression.ParseLambda(parameters, null, resultsSelector, values);
return outer.Provider.CreateQuery(
Expression.Call(
typeof(Queryable), "GroupJoin",
new Type[] { outer.ElementType, inner.AsQueryable().ElementType, outerSelectorLambda.Body.Type, resultsSelectorLambda.Body.Type },
outer.Expression, inner.AsQueryable().Expression, Expression.Quote(outerSelectorLambda), Expression.Quote(innerSelectorLambda), Expression.Quote(resultsSelectorLambda)));
}
public static IEnumerable GetList(System.Type type)
{
return (IEnumerable)Activator.CreateInstance(typeof(List<>).MakeGenericType(type));
}
该法典给我留下以下错误:
没有关于类型系统的通用方法组。 Linq。 证据符合所提供的类型论点和论点。 如果该方法是非遗传性的,则不应提供任何类型的论据。
In looking at the results of each piece they seem to match: Writing the follwing GroupJoin:
man.Contacts.GroupJoin(man.ContactAddresses, param_0 => param_0.ContactId, param_0 => param_0.ContactId,
(outer, inner) => new { ContactId = outer.ContactId, FirstName = outer.FirstName, LastName = outer.LastName, MI = outer.MiddleInitial, ContactAddresses = inner });
我收到了以下的ug:
.Call System.Linq.Queryable.GroupJoin(
.Constant<IdeaBlade.EntityModel.EntityQueryProxy`1[LOC.AMP.Data.DomainModel.Contact]>(IdeaBlade.EntityModel.EntityQueryProxy`1[LOC.AMP.Data.DomainModel.Contact]), .Constant<IdeaBlade.EntityModel.EntityQueryProxy`1[LOC.AMP.Data.DomainModel.ContactAddress]>(IdeaBlade.EntityModel.EntityQueryProxy`1[LOC.AMP.Data.DomainModel.ContactAddress]),
(.Lambda #Lambda1<System.Func`2[LOC.AMP.Data.DomainModel.Contact,System.Int64]>),
(.Lambda #Lambda2<System.Func`2[LOC.AMP.Data.DomainModel.ContactAddress,System.Int64]>),
(.Lambda #Lambda3<System.Func`3[LOC.AMP.Data.DomainModel.Contact,System.Collections.Generic.IEnumerable`1[LOC.AMP.Data.DomainModel.ContactAddress], <>f__AnonymousType0`5[System.Int64,System.String,System.String,System.String,System.Collections.Generic.IEnumerable`1[LOC.AMP.Data.DomainModel.ContactAddress]]]>))
.Lambda #Lambda1<System.Func`2[LOC.AMP.Data.DomainModel.Contact,System.Int64]>(LOC.AMP.Data.DomainModel.Contact $param_0)
{
$param_0.ContactId
}
.Lambda #Lambda2<System.Func`2[LOC.AMP.Data.DomainModel.ContactAddress,System.Int64]>(LOC.AMP.Data.DomainModel.ContactAddress $param_0)
{
$param_0.ContactId
}
.Lambda
#Lambda3<System.Func`3
[
LOC.AMP.Data.DomainModel.Contact, System.Collections.Generic.IEnumerable`1[LOC.AMP.Data.DomainModel.ContactAddress],
<>f__AnonymousType0`5
[
System.Int64,System.String,System.String,System.String, System.Collections.Generic.IEnumerable`1
[
LOC.AMP.Data.DomainModel.ContactAddress
]
]
]>
(LOC.AMP.Data.DomainModel.Contact $outer, System.Collections.Generic.IEnumerable`1
[LOC.AMP.Data.DomainModel.ContactAddress] $inner)
{
.New <>f__AnonymousType0`5[System.Int64,System.String,System.String,System.String,System.Collections.Generic.IEnumerable`1[LOC.AMP.Data.DomainModel.ContactAddress]](
$outer.ContactId,
$outer.FirstName,
$outer.LastName,
$outer.MiddleInitial,
$inner)
}
The following GroupJoin:
man.Contacts.GroupJoin(man.ContactAddresses, "ContactId", "ContactId", "new (outer.ContactId as ContactId, outer.FirstName as FirstName, outer.LastName as LastName, outer.MiddleInitial as MI, inner as ContactAddresses)");
然后看一下 de:
.Call GroupJoin (
{value(IdeaBlade.EntityModel.EntityQueryProxy 1[LOC.AMP.Data.DomainModel.Contact])}, {value(IdeaBlade.EntityModel.EntityQueryProxy 1[LOC.AMP.Data.DomainModel.ContactAddress])},
(.Lambda #Lambda1<System.Func 2[LOC.AMP.Data.DomainModel.Contact,System.Int64]>),
(.Lambda #Lambda1<System.Func 2[LOC.AMP.Data.DomainModel.ContactAddress,System.Int64]>),
(.Lambda #Lambda1<System.Func 3[LOC.AMP.Data.DomainModel.Contact,System.Collections.Generic.List`1[LOC.AMP.Data.DomainModel.ContactAddress],DynamicClass1]>)
//ContactId
.Lambda #Lambda1<System.Func 2[LOC.AMP.Data.DomainModel.Contact,System.Int64]>(LOC.AMP.Data.DomainModel.Contact $var1)
{
$var1.ContactId
}
//CA.ContactId
.Lambda #Lambda1<System.Func 2[LOC.AMP.Data.DomainModel.ContactAddress,System.Int64]>(LOC.AMP.Data.DomainModel.ContactAddress $var1)
{
$var1.ContactId
}
//Dynamic Result
.Lambda #Lambda1<System.Func`3[LOC.AMP.Data.DomainModel.Contact,System.Collections.Generic.List`1[LOC.AMP.Data.DomainModel.ContactAddress],DynamicClass1]>(
LOC.AMP.Data.DomainModel.Contact $outer,
System.Collections.Generic.List`1[LOC.AMP.Data.DomainModel.ContactAddress] $inner)
{
.New DynamicClass1(){
ContactId = $outer.ContactId,
FirstName = $outer.FirstName,
LastName = $outer.LastName,
MI = $outer.MiddleInitial,
ContactAddresses = $inner
}
}
The only thing different is List<T>
compared to IEnumerable. But List<T>
is IEnumerable.
The error reads like the signature is wrong. I just can t figure it out.
任何煽动都将是巨大的。