GVKun编程网logo

html – 在同一个元素上使用时,CSS first-child和last-child不起作用(css一个元素在另一个上面)

1

如果您想了解html–在同一个元素上使用时,CSSfirst-child和last-child不起作用和css一个元素在另一个上面的知识,那么本篇文章将是您的不二之选。我们将深入剖析html–在同一个

如果您想了解html – 在同一个元素上使用时,CSS first-child和last-child不起作用css一个元素在另一个上面的知识,那么本篇文章将是您的不二之选。我们将深入剖析html – 在同一个元素上使用时,CSS first-child和last-child不起作用的各个方面,并为您解答css一个元素在另一个上面的疑在这篇文章中,我们将为您介绍html – 在同一个元素上使用时,CSS first-child和last-child不起作用的相关知识,同时也会详细的解释css一个元素在另一个上面的运用方法,并给出实际的案例分析,希望能帮助到您!

本文目录一览:

html – 在同一个元素上使用时,CSS first-child和last-child不起作用(css一个元素在另一个上面)

html – 在同一个元素上使用时,CSS first-child和last-child不起作用(css一个元素在另一个上面)

我刚刚注意到,CSS:first-child和:last-child在同一个元素上使用时不起作用.只有一个被使用.我想知道为什么,如果在CSS中有任何解决方法?看起来像我的CSS bug – 第一个元素也可以是最后一个元素.

我在Google上找不到任何东西.每个教程假定将至少有2个元素.

我正在寻找像:“第一个孩子也是最后一个孩子”选择器.是否存在?

解决方法

I’m wondering why is that and if there is any workaround to that in CSS? It seems like CSS bug to me – first element can be also last element.

这不是一个bug.这是级联如何工作:如果一个元素是第一个孩子和最后一个孩子,那么如果你有:first-child和:last-child在单独的规则中,它们都匹配相同的元素,那么任何在后面声明的或更具体的规则将覆盖另一个.

您可以找到此行为here的一个示例,其中包含border-radius缩写属性,以及包含使用组件属性而不是缩写的解决方法,以及使用以下选择器之一指定单独的规则.

I’m looking for something like: “first child is also last child” selector. Does it exist?

从字面上来说,你会链接这样的伪类,这很好:

:first-child:last-child

但是,存在一种特殊的伪类,其行为方式相同:

:only-child

这两个选择器之间的主要区别(实际上是唯一的区别)是特异性:第一个更具体,因为它包含一个额外的伪类.即使在浏览器支持中也没有区别,因为:最后一个孩子和:唯一孩子都受到每个浏览器完全相同的版本的支持.

.NET 开发中基础问题,CODE First AND DB First (大牛自动忽略,小白可以看一下)

.NET 开发中基础问题,CODE First AND DB First (大牛自动忽略,小白可以看一下)

最近在做一个新项目开发时,碰到了下面这个问题。在使用 EF 时,提示错误信息

To continue using Database First or Model First ensure that the Entity Framework connection string is specified in the config file of executing application. To use these classes, that were generated from Database First or Model First, with Code First add any additional configuration using attributes or the DbModelBuilder API and then remove the code that throws this exception.

 

在网上也找了一些回复,但是基本都没有说明怎么解决的,我在这里说一下,

这个原因是因为 WEB.Config 中配置的连接字符串决定的。不同的连接字符串是不一样的

下面这种字符串是 CODE First 的,

<add name="XXXX" providerName="System.Data.SqlClient" connectionString="Data Source=XX.XX.X8.XX;Initial Catalog=XX;Persist Security Info=True;User ID=XX;Password=XX;"/>

通过 EF 同步数据库的类,应该使用下面这种链接字符串

<add name="XX" connectionString="metadata=res://*/XX.csdl|res://*/XX.ssdl|res://*/XX.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=XX.XX.XX.XX;initial catalog=XX;persist security info=True;user id=sa;password=XX;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

16. 翻译系列:EF 6 Code -First 中使用存储过程【EF 6 Code-First 系列】

16. 翻译系列:EF 6 Code -First 中使用存储过程【EF 6 Code-First 系列】

原文链接:https://www.entityframeworktutorial.net/entityframework6/code-first-insert-update-delete-stored-procedure-mapping.aspx

 

EF 6 Code-First 系列文章目录:

 

  • 1 翻译系列:什么是 Code First (EF 6 Code First 系列)
  • 2. 翻译系列:为 EF Code-First 设置开发环境 (EF 6 Code-First 系列)
  • 3. 翻译系列:EF Code-First 示例 (EF 6 Code-First 系列)
  • 4. 翻译系列:EF 6 Code-First 默认约定(EF 6 Code-First 系列)
  • 5. 翻译系列:EF 6 中数据库的初始化(EF 6 Code-First 系列)
  • 6. 翻译系列:EF 6 Code-First 中数据库初始化策略(EF 6 Code-First 系列
  • 7. 翻译系列:EF 6 中的继承策略(EF 6 Code-First 系列)
  • 8. 翻译系列: EF 6 中配置领域类(EF 6 Code-First 系列)
  • 9. 翻译系列:EF 6 以及 EF Core 中的数据注解特性(EF 6 Code-First 系列)
  •        9.1 翻译系列:数据注解特性之 ----Table【EF 6 Code-First 系列】
  •        9.2 翻译系列:数据注解特性之 ---Column【EF 6 Code First 系列】
  •        9.3 翻译系列:数据注解特性之 Key【EF 6 Code-First 系列】
  •        9.4 翻译系列:EF 6 以及 EF Core 中的 NotMapped 特性(EF 6 Code-First 系列)
  •        9.5 翻译系列:数据注解之 ForeignKey 特性【EF 6 Code-First 系列】
  •        9.6 翻译系列:数据注解之 Index 特性【EF 6 Code-First 系列】
  •        9.7 翻译系列:EF 数据注解特性之 --InverseProperty【EF 6 Code-First 系列】
  •        9.8 翻译系列:数据注解特性之 --Required 【EF 6 Code-First 系列】
  •        9.9 翻译系列:数据注解特性之 --MaxLength 【EF 6 Code-First 系列】
  •        9.10 翻译系列:EF 数据注解特性之 StringLength【EF 6 Code-First 系列】
  •        9.11 翻译系列:数据注解特性之 --Timestamp【EF 6 Code-First 系列】
  •        9.12 翻译系列:数据注解特性之 ConcurrencyCheck【EF 6 Code-First 系列】
  • 10. 翻译系列:EF 6 中的 Fluent API 配置【EF 6 Code-First 系列】
  •        10.1. 翻译系列:EF 6 中的实体映射【EF 6 Code-First 系列】
  •        10.2. 翻译系列:使用 Fluent API 进行属性映射【EF 6 Code-First】
  • 11. 翻译系列:在 EF 6 中配置一对零或者一对一的关系【EF 6 Code-First 系列】
  • 12. 翻译系列:EF 6 中配置一对多的关系【EF 6 Code-First 系列】
  • 13. 翻译系列:Code-First 方式配置多对多关系【EF 6 Code-First 系列】
  • 14. 翻译系列:从已经存在的数据库中生成上下文类和实体类【EF 6 Code-First 系列】
  • 15. 翻译系列:EF 6 中的级联删除【EF 6 Code-First 系列】
  • 16. 翻译系列:EF 6 Code -First 中使用存储过程【EF 6 Code-First 系列】
  • 17. 翻译系列:将 Fluent API 的配置迁移到单独的类中【EF 6 Code-First 系列】
  • 18. 翻译系列:EF 6 Code-First 中的 Seed Data(种子数据或原始测试数据)【EF 6 Code-First 系列】
  • 19. 翻译系列:EF 6 中定义自定义的约定【EF 6 Code-First 约定】
  • 20. 翻译系列:Code-First 中的数据库迁移技术【EF 6 Code-First 系列】
  •        20.1 翻译系列:EF 6 中自动数据迁移技术【EF 6 Code-First 系列】
  •        20.2. 翻译系列:EF 6 中基于代码的数据库迁移技术【EF 6 Code-First 系列】
  • 21. 翻译系列:Entity Framework 6 Power Tools【EF 6 Code-First 系列】

 

当 SaveChanges 方法被调用的时候,EF 6  可以用来创建并使用增删改存储过程。

我们来为下面的 Student 实体,创建增删改存储过程。

class Student
{
    public int StudentId { get; set; }
    public string StudentName { get; set; }
    public DateTime DoB { get; set; }
}

使用 MapToStoredProcedures () 方法,为实体配置默认的存储过程。

public class SchoolContext: DbContext 
{
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Student>()
                    .MapToStoredProcedures();
    }

    public DbSet<Student> Students { get; set; }
}

EF API 将会为 Student 实体创建 Student_InsertStudent_Update 和 Student_Delete存储过程。

 

 Student_Insert 和 Student_Update 存储过程包含 Student 实体的所有属性的参数,Student_Delete 存储过程仅仅包含 Student 的主键属性 StudentID 一个参数:

CREATE PROCEDURE [dbo].[Student_Insert]
    @StudentName [nvarchar](max),
    @DoB [datetime]
AS
BEGIN
    INSERT [dbo].[Students]([StudentName], [DoB])
    VALUES (@StudentName, @DoB)
    
    DECLARE @StudentId int
    SELECT @StudentId = [StudentId]
    FROM [dbo].[Students]
    WHERE @@ROWCOUNT > 0 AND [StudentId] = scope_identity()
    
    SELECT t0.[StudentId]
    FROM [dbo].[Students] AS t0
    WHERE @@ROWCOUNT > 0 AND t0.[StudentId] = @StudentId
END

CREATE PROCEDURE [dbo].[Student_Update]
    @StudentId [int],
    @StudentName [nvarchar](max),
    @DoB [datetime]
AS
BEGIN
    UPDATE [dbo].[Students]
    SET [StudentName] = @StudentName, [DoB] = @DoB
    WHERE ([StudentId] = @StudentId)
END

CREATE PROCEDURE [dbo].[Student_Delete]
    @StudentId [int]
AS
BEGIN
    DELETE [dbo].[Students]
    WHERE ([StudentId] = @StudentId)
END

 

为实体映射自定义的存储过程

 

EF6 允许你使用自己的存储过程,你可以像下面这样进行配置,下面的代码为 Student 实体,映射了一个自定义的存储过程。

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.Entity<Student>()
            .MapToStoredProcedures(p => p.Insert(sp => sp.HasName("sp_InsertStudent").Parameter(pm => pm.StudentName, "name").Result(rs => rs.StudentId, "Id"))
                    .Update(sp => sp.HasName("sp_UpdateStudent").Parameter(pm => pm.StudentName, "name"))
                    .Delete(sp => sp.HasName("sp_DeleteStudent").Parameter(pm => pm.StudentId, "Id"))
            );
}

在上面的例子中,Student 实体映射了三个存储过程,sp_InsertStudent、sp_UpdateStudent、以及 sp_DeleteStudent. 当然同样对存储过程的参数进行了配置。

 

为所有实体配置存储过程

 

你可以使用下面的代码,为所有实体配置存储过程。

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.Types().Configure(t => t.MapToStoredProcedures());
}

 

局限性

  • 仅仅只有 Fluent API 才能被用来映射存储过程。EF 6 中的数据注解特性,是不能映射存储过程的。
  • 如果你想使用 CUD 操作,你就必须为实体映射 Insert,Update 以及 Delete 存储过程。仅仅是映射其中一个,是不被允许的。

 

asp.net-mvc-4 – EF Code First,Model First或Db First?对于许多不断变化的中型应用程序

asp.net-mvc-4 – EF Code First,Model First或Db First?对于许多不断变化的中型应用程序

我们将使用MVC 4和EF 5为私营公司开发一个中大型定制Web应用程序.

早期分析和之前在该业务领域的经验表明,它将拥有超过150个表/实体,因为我们的客户不是软件工程师,我们知道我们的数据模型将在项目进展中多次改变.

现在,根据以下内容,我的Q是哪种方法对我们更好:

1)由于会发生许多变化,因此更新数据模型和数据存储的工作量减少.

2)创建数据存储所需的时间更少,并有助于更快地推进项目.

注意:此应用程序将使用大量数据(对于某些实体,10k,100k对象).但是,它将很少(有时可能没有)并发请求和在线用户.

提前致谢

解决方法

我认为这个词

because our customer isn’t a software engineer and we kNow that our
data model will change many times

是现实,但不是数据模型多次改变的全部原因!
BTW一些​​建议可能会有所帮助
将业务分析视为关键点,并继续进行业务分析
越来越多的分析投资将降低开发和变更管理的成本
让一位特定才华横溢的分析师作为客户办公室的代表.
有一个特定的客户代表负责分析和开发团队.
记录客户的业务流程,与客户讨论.记录谈判结果.
设计和变更管理
永远不要单独设计数据库.头脑风暴团队成员,邀请客户代表,邀请业务分析师,在设计团队中拥有DBA,具有Change-Manager角色.
技术
看看技术趋势(可能使用基于文档的数据库会有所帮助)
拥有灵活的框架和架构,为商业软件生产服务,而不是相反!
变化将来……准备好了
变化将会到来,所有上述努力都旨在优化解决方案,以便在变更发生时降低成本,它们不会阻止变更.
您需要有一个可接受的机制来向客户开账单
ITIL’s服务级别管理,SLA和OLA将成为指导.

所以问题的答案是:
1)以上所有内容都有助于解决问题.首先使用模板方法继续进行交互式分析,然后进行下一次设计并在迭代中进行开发.这将会产生成本.
2)取决于技术和框架,将有工具(我不知道EF)只是不坚持特定的平台或库.

希望这可以帮助.

c# – 出于EF linq查询的目的,First(c => cond)等于Where(c => cond).First()?

c# – 出于EF linq查询的目的,First(c => cond)等于Where(c => cond).First()?

是否有任何隐藏的微妙,是一个被推崇,还是只是一个更短的方式来写另一个?

Client = db.Clients.First(c=>c.Name == "Client 1")

Client = db.Clients.Where(c=>c.Name == "Client 1").First()

解决方法

是的他们是等同的.

简单测试它将它们添加到LINQPad并查看生成的sql语句,并在我的数据库中获得完全相同的Queries生成.

更新:

下面是我对我的数据库的查询示例.

-- Region Parameters
DECLARE @p0 VarChar(1000) = 'SKY02'
-- EndRegion
SELECT TOP (1) [t0].[MST_SQ],[t0].[EMP_EMPNO]
FROM [EMPLOYEE] AS [t0]
WHERE [t0].[EMP_EMPNO] = @p0
GO

-- Region Parameters
DECLARE @p0 VarChar(1000) = 'SKY02'
-- EndRegion
SELECT TOP (1) [t0].[MST_SQ],[t0].[EMP_EMPNO]
FROM [EMPLOYEE] AS [t0]
WHERE [t0].[EMP_EMPNO] = @p0

今天关于html – 在同一个元素上使用时,CSS first-child和last-child不起作用css一个元素在另一个上面的介绍到此结束,谢谢您的阅读,有关.NET 开发中基础问题,CODE First AND DB First (大牛自动忽略,小白可以看一下)、16. 翻译系列:EF 6 Code -First 中使用存储过程【EF 6 Code-First 系列】、asp.net-mvc-4 – EF Code First,Model First或Db First?对于许多不断变化的中型应用程序、c# – 出于EF linq查询的目的,First(c => cond)等于Where(c => cond).First()?等更多相关知识的信息可以在本站进行查询。

本文标签: