score:1
Accepted answer
i fooooooooooound. i'm very happy.
only , i replaced the following method :
private static ienumerable<expression> getconditionswithsubmodel(string search, parameterexpression pe,
string parameter)
{
// output.where(d => d.jn_newscategories.newscategoriesen.contains(""));
var expressions = new list<expression>();
var strings = parameter.split('$');
var modelname = strings[0];
var submodelname = strings[1].split('.')[0];
var submodelfield = strings[1].split('.')[1];
foreach (var splitseacrh in search.split(' '))
{
type modelclass = getmodel(modelname);
type submodelclass = getmodel(submodelname);
parameterexpression pesubmodel = expression.parameter(modelclass, "d");
expression leftsubmodel = expression.property(pesubmodel, modelclass.getproperty(submodelname));
expression ex = expression.property(leftsubmodel, submodelclass.getproperty(submodelfield));
expression rightsubmodel = expression.constant(splitseacrh);
methodcallexpression conditionexpressionsubmodel = expression.call(ex,
typeof(string).getmethod("contains"), rightsubmodel);
expressions.add(conditionexpressionsubmodel);
}
return expressions;
}
with following method :
private static ienumerable<expression> getconditionswithsubmodel(string search, parameterexpression pe,
string parameter)
{
// output.where(d => d.jn_newscategories.newscategoriesen.contains(""));
var expressions = new list<expression>();
var strings = parameter.split('$');
var modelname = strings[0];
var submodelname = strings[1].split('.')[0];
var submodelfield = strings[1].split('.')[1];
foreach (var splitseacrh in search.split(' '))
{
type modelclass = getmodel(modelname);
type submodelclass = getmodel(submodelname);
expression leftsubmodel = expression.property(pe, modelclass.getproperty(submodelname));
expression ex = expression.property(leftsubmodel, submodelclass.getproperty(submodelfield));
expression rightsubmodel = expression.constant(splitseacrh);
methodcallexpression conditionexpressionsubmodel = expression.call(ex,
typeof(string).getmethod("contains"), rightsubmodel);
expressions.add(conditionexpressionsubmodel);
}
return expressions;
}
Source: stackoverflow.com
Related Query
- The parameter '***' was not bound in the specified LINQ to Entities query expression
- The parameter 'd' was not bound in the specified LINQ to Entities query expression
- "The parameter was not bound in the specified LINQ to Entities query expression." Specification Pattern And
- The parameter 'p' was not bound in the specified LINQ to Entities query expression
- Getting error "The parameter was not bound in the specified LINQ to Entities query expression."
- code first approach error: the specified type member 'yyyxx' is not supported in linq to entities
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Refactor Linq code and "LINQ to Entities does not recognize the method"
- The specified type member 'Title' is not supported in LINQ to Entities
- The specified type member 'UserName' is not supported in LINQ to Entities
- LINQ Entities build Query at Runtime 'The parameter is not in scope.' LinqKit
- The specified type member 'Offset' is not supported in LINQ to Entities
- Adding a second query inside the SELECT of a LINQ to Entities query gives Not Recognized Method error
- The specified type member is not supported in LINQ to Entities
- TimeSpan: The specified type member 'TotalHours' is not supported in LINQ to Entities
- Get next element from Query after element with specified Id. The LINQ expression could not be translated
- The entity or complex type ' ' not be constructed in a LINQ to Entities query
- LINQ to Entities does not recognize the method in query
- Reconfigure Linq query to create objects: LINQ to Entities does not recognize the method
- The specified type member 'Disabled' is not supported in LINQ to Entities only when using .ToDataSourceResult()
- Entity Framework refusing Date comparison The specified type member 'Date' is not supported in LINQ to Entities
- The specified type member 'TimeBandDescription' is not supported in LINQ to Entities
- The query specified in the URI is not valid + Projection + LINQ Select
- Entity Framework Code First - The entity or complex type cannot be constructed in a LINQ to Entities query
- The specified type member is not supported in LINQ to Entities occurs when a new property is added in the partial class
- The specified type member 'Product' is not supported in LINQ to Entities
- The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties
- LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression
- LINQ to Entities does not recognize the method
- LINQ to Entities does not recognize the method 'System.String Format(System.String, System.Object, System.Object)'
More Query from same tag
- Is there a way to get the difference between two sets of objects in c#
- Entity framework get the foreign key
- multiple resultsets vs multiple calls for performance
- Building a List from another list and other sources in C#
- Dynamic Linq OrderBy null error
- Linq query with aggregates
- include multiple objects inside an object [Entity framework]
- Use a value from reflection in a LINQ query
- How to group items by index? C# LINQ
- Check if chars of a string contains in another string with LINQ
- How to recursively call Where clause in Linq or SQL
- Select a single object from Entity IQueryable List of object
- A better way than having 3 nested for loops to get data I need
- Are these the simplest ways to apply several different actions to a list of strings using LINQ?
- Select rows based on group by counts
- Process MusicBrainz Web Service
- Compare dates without seconds and milliseconds with LINQ in EF Core
- Dynamic LINQ OR Conditions
- LinQ query, only one record submitted/inserted
- Implement C# Linq Distinct Help in order to group a column in table
- Simple LINQ query
- Expression trees for dummies?
- Left Join In Entity Framework 6
- Recursive linq to get infinite children
- LINQ: Split list into groups according to weight/size
- orderby not working to get top 1 result in subquery using LINQ
- Why removing objects from a list with duplicate properties of types double in C# does not give consistent result using different methods?
- Nhibernate Map composite element
- how can I translate my SQL statement to LINQ
- Calculate Percentile using LINQ