TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vinoth vinoth
NA
315
5.5k
Linq Dynamic query for getting dynamic list based on Id
Dec 6 2017 1:13 AM
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);
}
Reply
Answers (
1
)
Please need HELP! to solve the following. c# newbie
Below is the code . i want do it using only one for loop.