【将接口映射到(动态地)不实现接口C#的Class】教程文章相关的互联网学习教程文章

c#-没有模型属性的实体框架映射结构/复杂类型【代码】

我有一个’model struct’在内部是一个字符串,但是被用来在某种程度上类似于GUID.public struct Token {private string _value;private Token(Guid uuid) {_value = Token.FromGuid(uuid);}public static Token FromGuid(Guid uuid) {// perform 'transformation'// stuff// return...}// other static methods to create a token...}如何使用Entity Framework 6 Code First映射此实体?我知道不支持结构,但是复杂的类型似乎也不适...

将接口映射到(动态地)不实现接口C#的Class【代码】

这是我在Stackoverflow中的第一篇文章.多亏了Stackoverflow. 我的问题: 我在类库中有一个接口.namespace TestClient {public interface IMobileStore{List<string> GetMobileDetails();int AddMobile(string mobile);} }我在另一个类库中有一个名为MobileLibrary的类,并实现了IMobileStore接口(在开发时)namespace MobileLibrary {public class MobileLibrary : IMobileStore{List<string> GetMobileDetails(){return new List<s...

c#-实体框架中每种类型的流利表映射【代码】

使用Entity Framework,我可以将相关表映射为类继承,并且可以通过三种不同的方法来表示继承层次结构(按weblogs): >每个层次表(TPH)>每个类型的表格(TPT)>每个具体类别的表(TPC) mscblogs站点对每种方法都有很好的解释. 我试图了解如何使用方法TPT(每种类型的表)映射表,但是与mscblogs的示例不同,我需要对流利的编程进行映射,例如:using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfigurati...

c#-将实体oneToMany与流利的nhibernate映射【代码】

问题似乎很简单,但是尝试映射此实体时遇到了很多麻烦.我只是看不到我在做什么错.你们能帮我吗? 我有Cliente类:public class Cliente { public Cliente () { }public virtual int ClienteId { get; set; } public IList<Medidor> ListaMedidores { get; set; } public virtual string NumeroMedidor { get; set; } }以及Medidor类public class Medidor {public Medidor() { }public virtual string NumeroMedidor { ...

c#-无法在映射器中映射属性【代码】

我创建了一个PropertyMapper,将属性从源映射到目标.public static void PropertyMap<T, U>(T source, U destination)where T : class, new()where U : class, new() {List<PropertyInfo> sourceProperties = source.GetType().GetProperties().ToList<PropertyInfo>();List<PropertyInfo> destinationProperties = destination.GetType().GetProperties().ToList<PropertyInfo>();foreach (PropertyInfo sourceProperty in sourceP...

c#-仅映射一个控制器及其操作的路由.其他路由设置可操作【代码】

首先,我需要说的是我正在使用T4MVC.我的RouteConfig中有许多自定义路由.这是一个例子:routes.MapRoute("CollectionDetails", "collection/{slug}/{collectionId}", MVC.Collection.CollectionDetails()); .............................................. routes.MapRoute("Sales.Index", "sales", MVC.Sales.Index());routes.MapRoute("CustomPage", "custom/{slug}", MVC.CustomPage.Index());所有这些...

c#-Dapper-将具有未知列数的结果集映射到具有数组属性的对象【代码】

我正在使用Dapper将来自SQL Server数据库的对象映射到C#类.根据上下文,我需要从中获取结果的存储过程之一可以具有可变数量的列.该结果集将始终具有一个主键列,然后具有0至30个其他列,它们都将具有相同的数据类型. 结果集列基本上是这样的:CustomerID | Email1 | Email2 | Email3 | ...电子邮件*列的数量取决于查询中客户对文件的最高电子邮件地址数量. 用C#捕获这种情况的自然方法是使用这样的类:class Customer {int ID { get; ...

c#-Automapper将int属性值从List映射到List【代码】

我需要将int属性从对象列表映射到List< int>.这是我的类结构: 我有一个家长班:public class Parent {...public List<Location> Locations { get; set; } }位置类别:public class Location {public int LocationId { get; set; }public string Name { get; set; } }映射的目标类:public class Destination {...public List<int> Locations { get; set; } }这是我尝试用来完成List< Location>与列出< int&gt ;: CreateMap<Paren...

c#-将具有相同名称的字段映射到自动映射器中的不同文件【代码】

我有一个要从.net core 2.0中的Match类映射的模型.这两个类都具有Name属性. 我需要映射Match.Value =>查看公司名称 但这总是将Match.Name放入ViewCompany.Name 这是我的AutomapperProfile:CreateMap<Match, ViewCompany>().ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Value));.ForMember(目的地=>目标名称,opt => opt.MapFrom(src => src.Value)) 查看公司:public class ViewCompany {public ViewCompany(){}p...

c#-使用结构化映射的命名会话实例策略进行Setter insection【代码】

我正在使用结构图,并想将实例(由容器构造)注入控制器的属性中.实例应命名并存储在http会话上下文容器中.在我的应用程序的先前版本中,我使用了自定义DI框架,并且可以很容易地进行如下操作:public class MyController : Controller {[InjectSession("MySessionInstanceKey")]public MyManager Manager {get; set;} }有没有简单的方法可以做到这一点?或者,也许我可以将自定义属性和注入逻辑引入SM框架(以某种方式扩展框架)?请帮助我...

c#-流利NHibernate将IList作为值映射到单列【代码】

我有这个课:public class MyEntity {public virtual int Id { get; set; }public virtual IList<Point> Vectors { get; set; } }如何将Fluent NHibernate中的Vector映射到单个列(作为值)?我在想这个:public class Vectors : ISerializable {public IList<Point> Vectors { get; set; }/* Here goes ISerializable implementation */ }public class MyEntity {public virtual int Id { get; set; }public virtual Vectors Vector...

c#-BLToolkit中的字段映射到类类型的属性【代码】

我的表架构(节选)create table dbo.MyEntity (MyEntityID int identity not nullprimary key,Name nvarchar(50) not nullunique,Description nvarchar(500) null,-- these two are optional fieldsMaxCount int null,MinSpace int null )实体类别[MapField("MaxCount", "Rule.MaxCount")] [MapField("MinSpace", "Rule.MinSpace")] public class MyEntity {public int Id { get; set; }public string Name { get; set; }public str...

c#-一种游戏设计解决方案,用于映射具有许多可以应用的变异的大型属性数据集.【代码】

我在设计声音设计方面遇到了一些麻烦,因为对我来说这是一个相当棘手的模块.实际的业务逻辑使我陷入混乱,所以我将其重新表述为更易于理解的形式.我用C#编写代码,尽管我猜实际的设计与语言无关. 假设您正在编写一个简单的幻想角色扮演游戏.您有一个具有一些基本属性的播放器.玩家可以装备一些物品,这可能会在某种程度上影响他的属性.项目具有一个或多个属性,这些属性定义要修改的属性.public Character {public string charName;publ...

c#-在EF 4上映射外键而不创建新的Edmx文件

我通过取消选中用于创建外键实体的选项来创建edmx文件,因此我的外键字段没有映射.是否可以在不创建新edmx文件的情况下映射外键?如果可能的话.我从已经存在的数据库中创建了.edmx.我正在使用VS 2012.解决方法:右键单击edmx,从数据库中单击更新模型.那里有一个用于外键的复选框.那是您要找的东西吗?

c#-实体框架5-抽象类型’X’没有映射的后代,因此无法映射【代码】

尝试在this object上操作时出现以下错误.有人有想法吗? project在GitHub上,但是除非周围有FIX服务器,否则您极有可能无法运行它.我似乎无法联网此错误消息.System.InvalidOperationException was unhandled by user codeMessage=The abstract type 'QuickFix.Fields.IField' has no mapped descendents and so cannot be mapped. Either remove 'QuickFix.Fields.IField' from the model or add one or more types deriving from '...

CLASS - 相关标签