我想共同使用我的接口(接口必须是共变体)但编译器给我错误c#编译器错误: - '参数必须输入安全.方差无效.类型参数'T'必须在'Expression'上不变有效这是我的代码:
interface IRepository<out T> where T : BaseEntity
{
IEnumerable<T> Find(Expression<Func<T, bool>> predicate);
T FindById(Guid id);
}
Run Code Online (Sandbox Code Playgroud) 我有n层应用程序,在不同的程序集中有许多层.我使用实体框架6.1,我想向ObjectState基础实体添加属性以跟踪实体状态.问题是BaseEntity位于我的域对象dll,它是独立ObjectState于数据库的,我想在Entity Framework项目中添加,因为这个属性是与实体框架相关的.如何实现这种行为?
public enum ObjectState
{
Unchanged,
Added,
Modified,
Deleted
}
public interface IObjectState
{
[NotMapped]
ObjectState ObjectState { get; set; }
}
Run Code Online (Sandbox Code Playgroud) 我有一个具有值对象的实体,该值对象具有另一个值对象.我的问题是,在更新实体和值对象时,具有父值对象的实体会更新,但子值对象不会更新.请注意,我使用的是最新版本的Entity Framework Core 2.1.0-rc1-final,这是父实体Employee
public class Employee : Entity
{
public string FirstName { get; private set; }
public string LastName { get; private set; }
public string Email { get; private set; }
public Address Address { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
这是父值对象Address
public class Address : ValueObject<Address>
{
private Address() { }
public Address(string street, string city, string state, string country, string zipcode, GeoLocation geoLocation)
{
Street = street;
City = city;
State = state;
Country = country; …Run Code Online (Sandbox Code Playgroud) c# value-objects entity-framework-core entity-framework-core-2.1
我正在设置持续集成和持续交付基础设施,我的解决方案包含 Web 项目、dll 和控制台应用程序。我的问题是,除了控制台应用程序之外,我的所有项目都包含在构建工件中这是我使用的默认 MSBuild 参数
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"
Run Code Online (Sandbox Code Playgroud) 我使用automapper从dtos映射到域,反之亦然; 我正在使用自定义类型转换器进行转换,但我想使用简单的注入器ioc将依赖项注入到我的转换器类中; 我做不到.请告诉我如何实现这一目标?
public class DtoToEntityConverter : ITypeConverter<Dto, Entity>
{
private readonly IEntityRepository _entityRepository;
public DtoToEntityConverter (IEntityRepository entityRepository )
{
_entityRepository = entityRepository ;
}
public Entity Convert(ResolutionContext context)
{
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个拥有类型的实体,我想与另一个实体建立关系,但拥有的类型示例中存在外键属性:- 这是我的员工实体
public sealed class Employee : AuditedAggregateRoot
{
public WorkInformation WorkInformation { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
它包含一个名为 WorkInformation 的值 Object(Owned Type)
public class WorkInformation : ValueObject<WorkInformation>
{
private WorkInformation()
{
}
public int? DepartmentId { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
我需要在员工和部门之间建立关系
public class Department : AuditedAggregateRoot
{
}
Run Code Online (Sandbox Code Playgroud)
我使用以下 Fluent 配置来执行此操作,但出现错误
builder.OwnsOne(e => e.WorkInformation)
//Add Employee Relations
builder.HasOne<Department>()
.WithMany()
.IsRequired(false)
.HasForeignKey(e => e.WorkInformation.DepartmentId);
Run Code Online (Sandbox Code Playgroud)
如果我将 DepartmentId 移动到所有者实体,它工作正常。
如何获取没有命名空间或文化或公钥令牌的程序集名称(只有名称); typeof(MyClass).AssemblyQualifiedName --->给我一个完全限定的名称,我只想要程序集名称而不是限定名称
创建自定义选项列表属性时,动态 crm 会创建另一个虚拟属性。我想知道动态crm中虚拟属性的用途。
我想在ServiceStack ormlite中使用paraemeters执行SQL语句
String.Format("SELECT OBJECT_ID(@name)", name);
Run Code Online (Sandbox Code Playgroud)
我想要最好的方式.
c# ×7
.net ×1
automapper ×1
covariance ×1
dbcontext ×1
dynamics-crm ×1
reflection ×1
servicestack ×1
tfs ×1
tfsbuild ×1