c# - Entity Framework DbSet dynamic query -


I have been I am a DbSet of a type that passed me database for a dynamic field and value Need to query. Using Generic Where I use the function with Lambda Expression. Can it be obtained from a standard dbSet that is made as follows?

  DbSet table = dataContext.Set (EntityType); PropertyInfo propertyInfo = EntityType.GetProperty (property name); // Expression: "Unit" parameter Expiration parameter = expression. Parameter (EntityType, "entity"); // expression: "entity.PropertyName" member Akspereshn Property Value = Expression.MakeMemberAccess (parameter, propertyInfo); // expression: "value" object converted value = Knhwartkchenj type (value, propertyInfo.PropertyType); Constant expression rhs = expression Constant (Convert Value); // Expression: "entity.PropertyName == Value" binary expression equal = expression. Aqual (property value, ra); // Expression: "unit => entity.property name == value" lambdaexression lambda = expression. Lambda (par, parameter);  

Now the table needs to be queryed to obtain data.

'system.ink. There is a Nougat package called 'Dynamic'.

This package allows you to make a statement against Dibisti the use of strings, such as:

MyContext.MyDbSet.Where ( "property name = = @ 0 "," Ave ");

It is possible to do with the expression to it, as you suggest in your question, but this library of all the heavy lifting.

I have used it with great success in one of my previous projects.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -