Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
发布NBearV3.1.7,包含重要升级内容:强类型实体集合 、Gateway缓存等
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 9 2006, 11:09 pm
From: Teddy <shijie...@gmail.com>
Date: Fri, 10 Nov 2006 12:09:50 +0800
Local: Thurs, Nov 9 2006 11:09 pm
Subject: 发布NBearV3.1.7,包含重要升级内容:强类型实体集合、Gateway缓存 等

简单说明一下本次升级可能导致的额外代码修改:

1、强类型实体集合

新增的强类型实体集合会将设计实体中的Domain[] Domains这样的数组形式的关联属性,生成为最终实体中的DomainArrayList
Domains属性。

每一个实体,如Domain都会多生成一个形如DomainArrayList的集合类型,使用该集合可以添加、删除、清空关联到属性的对象。当属性设置Con tained时,和原来使用Domain[]
Domains一样,能够自动级联更新/删除。原来的Entity.AddArrayItem/RemoveArrayItem等方法已经删除。

2、为Gateway新增简单的缓存支持。可以以如下格式配置config文件,注意cacheConfig配置节。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="entityConfig" type="
NBear.Common.EntityConfigurationSection, NBear.Common" />
*    <section name="cacheConfig" type="NBear.Data.CacheConfigurationSection,
NBear.Data" />*
  </configSections>
  <entityConfig>
    <includes>
      <add key="Sample"
value="C:\Teddy\NBearV3\src\NBear.Test.UnitTests\EntityConfig.xml" />
    </includes>
  </entityConfig>
*  <cacheConfig enable="true">
    <cachingTables>
      <add key="Northwind.Orders" value="5" />
    </cachingTables>
  </cacheConfig>
*  <connectionStrings>
    <add name="Northwind"
connectionString="Server=(local);Database=Northwind;Uid=sa;Pwd=sa"
providerName="NBear.Data.SqlServer.SqlDbProvider"/>
  </connectionStrings>
</configuration>

这里的每一项add可以指定一个数据库表或存储过程的名称和缓存的时间(单位:秒)。

例如,Northwind.Orders中,Northwind
表示对应的ConnectionString配置节的名称,Orders是数据库中的表名(注意是表名而不是实体类的名称)或存储过程名称。

当如上配置后,默认的以Northwind这个ConnectionString初始化的Gateway实例将是自动开启了读缓存支持的。
可以使用Gateway.TurnOnCache()/TurnOffCache()方法改变当前Gateway实例是否使用缓存。

一般来讲,对于每一个ConnectionString,我们可以实例化两个Gateway,一个专门用于有缓存的读数据,另一个用于无缓存的读数据。另一方面 ,无论是否开启缓存支持,对于写操作没有影响。

3、Entity.EntityArrayToDataTable()现在支持输入一个空数组或者null返回一个只包含实体结构的空的DataTable实例 。

Teddy


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
勇敢的心  
View profile   Translate to Translated (View Original)
 More options Nov 10 2006, 12:24 am
From: "勇敢的心" <my...@163.com>
Date: Thu, 09 Nov 2006 21:24:27 -0800
Local: Fri, Nov 10 2006 12:24 am
Subject: Re: 发布NBearV3.1.7,包含重要升级内容:强类型实体集合、Gateway缓存 等
实体的定义可以简化吗?我想用你的组件做开发,可是怕以后维护的工作量很大,能不能像GroveKit一样不需要实体接口,直接定义实体类,这样用起来比较简单 。
还有实体的配置能不能做一个工具,提供用户界面,直接从数据生成太死板了。那样也能生成单表或单视图的实体。
还有一点很重要:如下:
public interface User : Entity
{
     [PrimaryKey]
     Guid UserID {get;set;}
     [SqlType("nvarchar(20)")]
     string UserName { get;set;}
     [SqlType("nvarchar(20)")]
     string Password {get;set;}
}

如果以上接口没有实现类,返回数据就不能以
public User GetUser(Guid UserID)的形式返回
可定义实体类太复杂,而且还需要配置XML文件

还有怎么指定一个字段为标识种子列呢?

多表关连可不可以用一个实体类来做,做关联关系。而不是用另一个实体类来关联,这样给人感觉没能单体类直观。虽然可以做视图,但维护起来还是比较复杂的。视图改 了还得改实体。

可以参照GroveKit,只是建议,也许你有更好的实现方法。我觉得它用起来还比较方便,只是不开源,效率也不是很高,下个项目中想改用你的组件。
namespace HappyLife.Entity
{
    using System;
    using Grove.ORM;
    [Serializable]
    [RelationTable("bas_tb_uservisitRelationQuery", BeginWithTable =
"bas_tb_uservisit")]
    public class uservisitinfo
    {
        [RelationReflect("bas_tb_uservisit", "art_tb_works", JoinType =
TableJOINType.LEFTOUTERJOIN)]
        [RelationField("workid", "workid")]
        public string Relationship_1
        {
            get { return
"[bas_tb_uservisit].[workid]=[art_tb_works].[workid]"; }
        }
        [RelationReflect("art_tb_works", "bas_tb_user", JoinType =
TableJOINType.LEFTOUTERJOIN)]
        [RelationField("userid", "userid")]
        public string Relationship_2
        {
            get { return
"[art_tb_works].[userid]=[bas_tb_user].[userid]"; }
        }
        [RelationReflect("art_tb_works", "art_tb_workstypekind",
JoinType = TableJOINType.LEFTOUTERJOIN)]
        [RelationField("typeid", "typeid")]
        public string Relationship_3
        {
            get { return
"[art_tb_works].[typeid]=[art_tb_workstypekind].[typeid]"; }
        }
        [RelationReflect("art_tb_works", "art_tb_workstypekind",
JoinType = TableJOINType.LEFTOUTERJOIN)]
        [RelationField("kindid", "kindid")]
        public string Relationship_4
        {
            get { return
"[art_tb_works].[kindid]=[art_tb_workstypekind].[kindid]"; }
        }
        [RelationReflect("art_tb_workstype", "art_tb_workstypekind",
JoinType = TableJOINType.LEFTOUTERJOIN)]
        [RelationField("typeid", "typeid")]
        public string Relationship_5
        {
            get { return
"[art_tb_workstype].[typeid]=[art_tb_workstypekind].[typeid]"; }
        }

        String _username;
        [DataField("username", TableName = "bas_tb_user")]
        public String username
        {
            get { return this._username; }
            set { this._username = value; }
        }
        String _kindname;
        [DataField("kindname", TableName = "art_tb_workstypekind")]
        public String kindname
        {
            get { return this._kindname; }
            set { this._kindname = value; }
        }
        String _typename;
        [DataField("typename", TableName = "art_tb_workstype")]
        public String typename
        {
            get { return this._typename; }
            set { this._typename = value; }
        }
        Byte _typeid;
        [DataField("typeid", TableName = "art_tb_works")]
        public Byte typeid
        {
            get { return this._typeid; }
            set { this._typeid = value; }
        }
        Byte _kindid;
        [DataField("kindid", TableName = "art_tb_works")]
        public Byte kindid
        {
            get { return this._kindid; }
            set { this._kindid = value; }
        }
        String _worktitle;
        [DataField("worktitle", TableName = "art_tb_works")]
        public String worktitle
        {
            get { return this._worktitle; }
            set { this._worktitle = value; }
        }
        Boolean _iscommend;
        [DataField("iscommend", TableName = "art_tb_works")]
        public Boolean iscommend
        {
            get { return this._iscommend; }
            set { this._iscommend = value; }
        }
        Boolean _isenable;
        [DataField("isenable", TableName = "art_tb_works")]
        public Boolean isenable
        {
            get { return this._isenable; }
            set { this._isenable = value; }
        }
        Boolean _isdel;
        [DataField("isdel", TableName = "art_tb_works")]
        public Boolean isdel
        {
            get { return this._isdel; }
            set { this._isdel = value; }
        }
        Guid _visitid;
        [DataField("visitid", TableName = "bas_tb_uservisit")]
        public Guid visitid
        {
            get { return this._visitid; }
            set { this._visitid = value; }
        }
        Guid _userid;
        [DataField("userid", TableName = "bas_tb_uservisit")]
        public Guid userid
        {
            get { return this._userid; }
            set { this._userid = value; }
        }
        Guid _workid;
        [DataField("workid", TableName = "bas_tb_uservisit")]
        public Guid workid
        {
            get { return this._workid; }
            set { this._workid = value; }
        }
        DateTime _visittime;
        [DataField("visittime", TableName = "bas_tb_uservisit")]
        public DateTime visittime
        {
            get { return this._visittime; }
            set { this._visittime = value; }
        }
    }


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 10 2006, 12:41 am
From: Teddy <shijie...@gmail.com>
Date: Fri, 10 Nov 2006 13:41:50 +0800
Local: Fri, Nov 10 2006 12:41 am
Subject: Re: 发布NBearV3.1.7,包含重要升级内容:强类型实体集合、Gateway缓存 等

在NBear中,只需要定义
public interface User : Entity
{
    [PrimaryKey]
    Guid UserID {get;set;}
    [SqlType("nvarchar(20)")]
    string UserName { get;set;}
    [SqlType("nvarchar(20)")]
    string Password {get;set;}

}

就能使用自带的工具生成XML、最终实体类User和数据库创建脚本。几乎没有写XML和实体类的负担,你觉得哪方面麻烦呢?

另外,注意区分实体设计代码和工具生成的最终实体代码。设计代码是仅用于设计的,真正使用实体类的工程只需要引用最终实体代码,无须引用实体设计代码。也就是说 ,从使用实体的工程的视角来说,他看到的实体全部都是标准的class。不是接口。

-

可以简单的将一个属性,比如ID设计为只读PrimaryKey,它会自动映射数据库中的字增长ID类型。
例如,设计为如下代码:
public interface User : Entity
{
    [PrimaryKey]
    int UserID { get; }
    //...

}

-

对于继承体系和有关联关系的实体,在设计代码中设计完成后,工具能自动生成全部最终实体代码,配置文件,和数据库创建脚本。无须手动建数据表或XML或写实体类 代码的。

-

将实体元数据放在XML有其好处,就是方便在部署后动态更改。而且XML也是自动生成的,没有编码负担。

-

另外,注意,所有工具生成的最终实体代码都是partial类,你可以在独立的文件建partil类来扩展这些实体,比如添加方法,自定义属性什么的。part ial类带来的额外好处是,当实体设计有变化时,只要类名没变化,重新生成最终实体代码不会破坏独立的partial类的代码,维护和升级就很轻松了。

Teddy

On 11/10/06, 勇敢的心 <my...@163.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
勇敢的心  
View profile   Translate to Translated (View Original)
 More options Nov 10 2006, 1:16 am
From: "勇敢的心" <my...@163.com>
Date: Thu, 09 Nov 2006 22:16:59 -0800
Local: Fri, Nov 10 2006 1:16 am
Subject: Re: 发布NBearV3.1.7,包含重要升级内容:强类型实体集合、Gateway缓存 等
EntityArrayList
怎么使用,返回数据为Entity[]形式,怎么和EntityArrayList关联。
还得创建一个EntityArrayList,再将Entity[]加入到EntityArrayList再使用吗?
现在可不可以直接返回EntityArrayList,可Gateway里的方法全部都是返回Entity[]!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 10 2006, 1:28 am
From: Teddy <shijie...@gmail.com>
Date: Fri, 10 Nov 2006 14:28:40 +0800
Local: Fri, Nov 10 2006 1:28 am
Subject: Re: 发布NBearV3.1.7,包含重要升级内容:强类型实体集合、Gateway缓存 等

所有的EntityArrayList支持AddRange方法添加一组Entity[]。

On 11/10/06, 勇敢的心 <my...@163.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
勇敢的心  
View profile   Translate to Translated (View Original)
 More options Nov 10 2006, 1:34 am
From: "勇敢的心" <my...@163.com>
Date: Thu, 09 Nov 2006 22:34:30 -0800
Local: Fri, Nov 10 2006 1:34 am
Subject: Re: 发布NBearV3.1.7,包含重要升级内容:强类型实体集合、Gateway缓存 等
和我说的问题不相符啊,我是意思是能不能直接返回EntityArrayList,这样就不用再创建EntityArrayList后用AddRange方法了 。
在Gateway返回的时候就返回EntityArrayList不是更方便!是不是又有系列化的问题!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Nov 10 2006, 1:55 am
From: Teddy <shijie...@gmail.com>
Date: Fri, 10 Nov 2006 14:55:18 +0800
Local: Fri, Nov 10 2006 1:55 am
Subject: Re: 发布NBearV3.1.7,包含重要升级内容:强类型实体集合、Gateway缓存 等

系列化的问题倒不至于,但是,Gateway返回EntityArrayList一没有必要,二,EntityArrayList不是范型类,比可能为每个实体 都生成一个Gateway版本代码吧?再说,对于返回的数据,一般都不会去Add/Remove它的。而且,从Entity[]到EntityArrayLis t(AddRange)和从EntityArrayList到Entity[](ToArray),已经是比较方便的了。

On 11/10/06, 勇敢的心 <my...@163.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google