Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Linq Dynamic query for getting dynamic list based on Id
vinoth vinoth
Dec 6 2017 1:13 AM
179
Reply
I have created the Dynamic Model list.Here i need to get Dynamic list based on id.so I have tried the code. but i didn't get correct result.please help to get that
code:
public virtual List<TModel> GetAll(long index=0,string FieldName="")
{
try
{
_context.Set<TModel>().SelectByName<TModel,long>(FieldName).Distinct();
}
catch (Exception exc)
{
IsError = true;
ErrorMessage = exc.ToString();
Status = "Sorry,Not taken the Details";
}
return null;
}
public static IQueryable<V> SelectByName<T,V>(this IQueryable<T> source,
string FieldName)
{
ParameterExpression paramExp = Expression.Parameter(typeof(T), "x");
ConstantExpression valueexp = Expression.Constant(value);
MemberExpression memberExp = Expression.PropertyOrField(paramExp, FieldName);
var lambdaExp = Expression.Lambda<Func<T, V>>(memberExp, paramExp);
return source.Select(lambdaExp);
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Please need HELP! to solve the following. c# newbie
Below is the code . i want do it using only one for loop.