我如何在linq中将实体类型作为参数传递?
例如,该方法将接收实体名称值作为字符串,我想将实体名称传递给下面的linq查询.是否可以使linq查询通用?
public ActionResult EntityRecords(string entityTypeName)
{
var entityResults = context.<EntityType>.Tolist();
return View(entityResults);
}
Run Code Online (Sandbox Code Playgroud)
我想将实体类型作为参数传递并返回所有属性值.
此外,是否可以根据某些属性过滤结果?
我知道旧版本的 Spark 仅支持 java.math 中的 BigDecimal 类型。但我发现了这个拉取请求:https : //github.com/apache/spark/pull/10125。我尝试使用它,使用 BigInteger 类型没有问题。但是在spark 文档中仍然没有提到 BigInteger。那么,我可以安全地使用这种类型吗?
以下对象和集合初始值设定项的组合不会产生编译错误,但它根本就是错误的(https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object- and-collection-initializers #examples),因为该Add方法将用于初始化:
public class Foo
{
public List<string> Bar { get; set; }
}
static void Main()
{
var foo = new Foo
{
Bar =
{
"one",
"two"
}
};
}
Run Code Online (Sandbox Code Playgroud)
所以你会得到NullReferenceException.在开发语言语法时做出这种不安全决定的原因是什么?例如,为什么不使用新集合的初始化?
我在 asp.net C# 项目中实现了 Auto Mapper,但出现错误:
Mapper 不包含 Initialize 的定义
我试过这个例子链接在这里
我已经粘贴了我的代码:
namespace NewsWeb.Web.Infrastructure
{
public class AutomapperWebProfile:Profile
{
public AutomapperWebProfile()
{
CreateMap<DistrictDTO, District>().ReverseMap();
}
public static void Run()
{
Mapper.Initialize(a =>
{
a.AddProfile<AutomapperWebProfile>();
});
}
}
}
Run Code Online (Sandbox Code Playgroud)
在我的 Golbal.asax.cs 文件中:
AutomapperWebProfile.Run();
Run Code Online (Sandbox Code Playgroud)
c# ×3
apache-spark ×1
asp.net-mvc ×1
automapper ×1
c#-4.0 ×1
collections ×1
generics ×1
java ×1
linq ×1
reflection ×1
scala ×1