现在的位置: 首页 > 综合 > 正文

使用easyobjects asp.net ajax + mygeneration(1)

2014年01月19日 ⁄ 综合 ⁄ 共 3257字 ⁄ 字号 评论关闭
一直对ORM这个东西比较关注,对enterprise library 同样也比较关心,对asp.net ajax 也没有使用体验,mygeneration的模板也没有写过,综合起来,用这些东西结合目前本人想做的东东写个程序确实很又必要,通过这些达到以下目的:
1  Enterprise library  dataaccess block  的使用
2  asp.net ajax的使用
3  mygeneration 的使用及如何写一个模板
4 easyobjects的使用和学习其内部实现
5 vs2005一些控件的用法
之所以使用easyobjects 是因为其使用了enterprise library, 同时是free的,也比较小,可以直接轻松阅读并修改其实现。

接下来是这几天使用的方式:
1 用mygeneration 生成代码,主要是两个类,一个是实体,另外是包装实体的一个类,应该是facade概念,没有使用存储过程,目的为了代码的兼容,这里注意配置中设置  dbtarget: DbType(default setting中)
2 使用asp.net ajax的配置文件,其提供一个例子,用例子中的web.config, 然后添加 使用easyobjects 的设置,如果这个不大熟悉,查阅相关资料会告诉你用entlb配置工具配置,比较烦的,添加内容基本如下:

<configSections>
        
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
        
<section name="dynamicQueryConfiguration" type="NCI.EasyObjects.Configuration.DynamicQuerySettings, NCI.EasyObjects"/>
        
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
                
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                    
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
                    
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
                    
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
                
</sectionGroup>
            
</sectionGroup>
        
</sectionGroup>
    
</configSections>
  
<dataConfiguration defaultDatabase="Connection String" />
    
<connectionStrings>
        
<add name="Connection String" providerName="System.Data.SqlClient" connectionString="packet size=4096;user id=sa;data source=yourmachine;persist security info=True;initial catalog=yourdatabase;password=yourpass"/>
    
</connectionStrings>

3 在项目中添加引用 AjaxControlToolkit.dll Microsoft.Practices.EnterpriseLibrary.Common.  Data ObjectBuilder, NCI.EasyObjectsFree.dll  还有你自己的实现类库
4 开始添加记录了
         IntroText introText = new IntroText();
        introText.AddNew();
        introText.IntroName = this.txtIntroName.Text;
        introText.IntroductionText = this.txtIntroText.Text;       
        introText.Save();
是的,就是这样你可以实现其它业务了 :)

PS: 请参照 www.easyobjects.net

抱歉!评论已关闭.