N bear

Click here to load reader

download N bear

of 83

description

NBear PPT

Transcript of N bear

  • 1.
  • 2.
  • 3.
    • NBear .Net 2.0 C#2.0 NBear
    • BSD
  • 4.
    • N .Net No Bear
    • Bear .Net Bear NBear .Net2.0
    • Bear Web URL NBear nhibernate ORM NBear
    • NBear No Bear .Net2.0 Generic Emit HttpModule NBear No Bear NBear
  • 5.
    • NBear Entity XML/JSON Web
      • NBear ASP.NET 2.0 Web JSON XML
      • NBear.Web Web ASP.NET ORM NBear DAAB
  • 6.
      • XML JSON NBear Web Service Remoting .
      • IoC SOA SOA
      • NBear Hibernate
  • 7.
    • O/R ,
    • , ,
    • ,
    • , Emit
    • XML JSON
    • Provider
    • ,
    • .Net Remoting
    • ASP.NET MasterPage, Pae, UserControl
    • AJAX
    • URL
    • UI
  • 8.
    • NBear http://nbear.org
    • NBear at CodePlex: http://www.codeplex.com/nbear
    • | Team Blog: http://nbear.cnblogs.com
    • | Google Group: http://groups.google.com/group/nbeargroup
    • |SVN : https://svn.sourceforge.net/svnroot/nbear/trunk/
    • Teddy's Knowledge Base - : http://teddyma.cnblogs.com/
    • | CNBLOGS : http://www.cnblogs.com
  • 9.
  • 10.
      • ORM
      • IoC
      • NBear.Web
      • ORM NBearLite
  • 11.
      • 1.1 http://www.codeplex.com/nbear NBearV3
      • 1.2 zip C: NBearV3 dist doc cases src dist release dll exe
  • 12.
      • 2.1 VS2005 sln
      • 2.2 sln C# EntityDesigns Entities IDE Class1.cs
      • 2.3 sln website ASP.NET Web website Web.config
  • 13.
      • 3.1 2.2 EntityDesigns ClassDiagram.cd IDE
  • 14.
      • 3.2 EntityDesigns dist NBear.Common.Design.dll NBear.Common.Design.Entity Entities UserName struct FirstName LastName string Field Entities UserStatus Availale Deleted Entities EntityDesigns Entities Entities EntityDesigns
      • 3.3 ClassDiagram.cd 3.2 EntityDesigns Entities
  • 15.
      • 3.4 User NBear.Common.Design.Entity ID Name Status Birthday Guid UserName UserStatus DateTime? Name Status 3.2 UserName UserStatus Birthday Nullable DateTime? DateTime Nullable Birthday null
      • 3.5 LocalUser NBear.Common.Design.Entity LoginName Password string
      • 3.6 LocalUser User
  • 16.
    • 3.7 UserProfile NBear.Common.Design.Entity ID UserID ProfileContent Guid Guid string ProfileContent profile 1 1
  • 17.
    • 3.8 User Profile UserProfile 1 1 User UserProfile
  • 18.
    • 3.9 LocalUserPhone NBear.Common.Design.Entity ID UserID Description Number Guid Guid string string
    • 3.10 LocalUser Phones LocalUserPhone[] 1 LocalUser UserPhone
  • 19.
      • 4.1 UserGroup RelationKey PrimaryKey Attribute User ID
      • [PrimaryKey] GuidID { get; set; }
      • ID int ID int
      • [PrimaryKey] intID { get; }
  • 20.
    • 4.2 nullable NBear string string nvarchar(127) UserProfile ProfileContent Attribute ntext
    • [SqlType("ntext")] stringProfileContent { get; set; }
    • LocalUserPhone Number Attribute nvarchar(20)
    • [SqlType("nvarchar(20)")] stringNumber { get; set; }
  • 21.
  • 22.
    • 5.1 EntityDesigns
    • 5.2 dist NBear.Tools.EntityDesignToEntity.exe EntityDesigns EntityDesigns.dll
    • 5.3 Generate Entities Entities Entities.cs Entities distNBear.Common.Common.dll
    • 5.4 Generate Configuration website EntityConfig.xml
    • 5.5 Generate DB Script website db.sql SQL Server
  • 23.
  • 24.
  • 25.
  • 26.
    • 6.1 website Entities dist/NBear.Data.dll
    • 6.2 website Web.config entityConfig section EntityConfig.xml Web.config connectionstring SQL Server tempdb tempdb 5.5
  • 27.
  • 28.
  • 29.
    • 6.3 website Default.aspx.cs tutorials ORM_Tutorialwebsite Default.aspx.cs Gateway doc SDK
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
    • 6.4
    • Create a new local user and set property values. Create & set the user name. Create & set the local user phones Create & set the user groups. Save the new local user. After we saved the local user. We found the saved local user itself. We found the saved local user itself as a user. We found the 1 to 1 related user profile of the saved local user was also saved. Oh! many to many related local user group of the saved local user was NOT saved!! Do you know why? - It is NOT because it is many to many related while profile and phones are 1 to 1 or 1 to many. It is not because your are not Teddy, either. :) It IS because in the entity design of User, the Groups property is NOT marked with the [Contained] attribute. To save an uncontained property value, such as users Groups, you have to manually do this. Firstly, you should save the group it self. Furthermore, you have to create & save a usergroup relation entity manually. Lets do it. Lets find the saved local user again. Was the group saved this time? Yes, conguratulation! This time, we found the many to many related local user group of the saved local user was finally saved. Do you want to know the saved user names details, which is a compoundunit property? Ok, show you what you want, in fact, it is serialized as xml by the NBear.Common.SerializationManager class, looks like: teddyma Ok, I heard you considering whether you can save it into some other format because you do not want it to be XML? You do have chance to control this!! What youshould do is easily register a custom serialize/deserialize delegate method pair. Lets save the user name again. What does the details of the user name now become? It becomes: teddy,ma Cool!~~ Right? But remember, in real project, you must register the custom serialize/deserialize delegate method pair at application started up. For example, in Application_Start(). Thank you so much for having completed this tutorial. You can look up the appendixes, for more information about the usage of the Gateway. See you later! Warm regards, Teddy 2006-11-3
  • 37.
      • ORM
      • IoC
      • NBear.Web
      • NBearLite
  • 38.
      • 1.1 http://www.codeplex.com/nbear NBearV3
      • 1.2 zip C: NBearV3 dist doc cases src dist release dll exe
  • 39.
    • 2.1 VS2005 sln
    • 2.2 sln C# EntityDesigns Entities IDE Class1.cs
    • 2.3 sln C# ServiceInterfaces ServiceImpls IDE Class1.cs
    • 2.4 sln website ASP.NET Web website Web.config
  • 40.
    • 3.1 dist NBear.Tools.DbToEntityDesign.exe Connection String
    • Server=(local);Database=Northwind;Uid=sa;Pwd=sa
    • SQL Server 2000 Northwind
    • Connect Tables Views Category Product Categories Products Products by Category Generate Entities Design Copy to ClipBoard
    • 3.2 EntityDesigns dist NBear.Common.Design.dll NBear.Common.Design.Entity EntitiyDesigns EntityDesigns.cs using System using NBear.Common.Design namespace EntityDesigns DbToEntityDesign
  • 41.
  • 42.
    • EntityDesigns.cs
    • usingSystem; usingNBear.Common.Design; namespaceEntityDesigns { publicinterfaceCategories:Entity { [PrimaryKey] intCategoryID{get;} [SqlType("nvarchar(15)")] stringCategoryName{get;set;} [SqlType("ntext")] stringDescription{get;set;} byte[]Picture{get;set;} } // }
  • 43.
    • _nbsp_ PrimaryKey Attribute ReadOnly Attribute
  • 44.
    • 3.3 _nbsp_ MappingName Attribute Products_nbsp_by_nbsp_Category
  • 45.
    • Categories Category
  • 46.
    • MappingName Attribute _nbsp_
  • 47.
  • 48.
    • 4.1 EntityDesigns ORM Northwind
    • 4.2 dist NBear.Tools.EntityDesignToEntity.exe EntityDesigns EntityDesigns.dll
    • 4.3 Generate Entities Entities Entities.cs Entities distNBear.Common.Common.dll
    • 4.4 Generate Configuration website EntityConfig.xml
  • 49.
    • 5.1 website Entities dist/NBear.Data.dll
    • 5.2 website Web.config entityConfig section EntityConfig.xml Web.config
  • 50.
  • 51.
    • 6.1 NBear.IoC Service ServiceInterfaces distNBear.Common.dll distNBear.IoC.dll Service Service Category Product ServiceInterfaces Entities ServiceInterfaces ICategoryService IProductService
  • 52.
    • 6.2 Service ServiceImpls Entities ServiceInterfaces distNBear.Common.dll distNBear.Data.dll distNBear.IoC.dll
  • 53.
    • 7.1 ServiceImpls website Service website Entities ServiceInterfacs distNBear.Common.dll distNBear.IoC.dll
    • website ServiceImpls website ServiceImpls IoC IoC Service Service Service website Service ServiceImpls ServiceImpls.dll website Bin
  • 54.
    • 7.2 Web.config IoC NBearV3 IoC castle IoC castle
  • 55.
  • 56.
    • 7.3 Default.aspx.cs PageLoad Service
    • Service ServiceFactory.GetService()
  • 57.
  • 58.
    • website NBear.IoC.Service.ServiceFactory.Create() ServiceFactory Service
    • ServiceFactory ServiceFactory ServiceFactory.Create() ServiceFactory.Create() Singleton ServiceFactory
    • website ServiceFactory service Service ServiceFactory.Create() Web.config castle service Service Service Service Interfaces Service
  • 59.
      • ORM
      • IoC
      • NBear.Web
      • NBearLite
  • 60.
    • NBear.Web Page/MasterPage/UserControl ASP.NET 2.0 Ajax sf.net zip tutorialsWeb_Tutorial 1 Helper Methods - Web 2 ClientScriptFactory - JS 3 LoadResources()/GetString() - 4 AjaxHelper - UserControl AjaxHelper
  • 61.
    • NBear.Web Web NBear.Web.dll NBear .Net Framework 2.0/C# 2.0/ASP.NET 2.0 ASP.NET 2.0 NBear.Web NBear.Web.UI Page/MasterPage/UserControl WebForm MasterPage User Control Page MasterPage UserControl Page MasterPage UserControl MasterPage UserControl
  • 62.
    • HelperMethodsDemo.aspx NBear.Web.UI.Page 1) GetIntParam()/GetStringParam()/GetDateTimeParam() QueryString Form Form QueryString Form
  • 63.
    • 2) StrongTyped() (ReturnType)obj eval Session Session["hellotime"]=DateTime.Now; Response.Write(string.Format("TestStrongTyped(),currenttimeticks={0}
      ",StrongTyped(Session["hellotime"]).Ticks));
    • 3) TextToHtml()/ToXXXString()
  • 64.
    • Page.ClientScriptFactory JS JS JS JS ClientScriptFactoryDemo.aspx ClientScriptFactory aspx
  • 65.
  • 66.
    • .resx .resources Global.asax GlobalizationDemo.aspx ASP.NET 2.0 ASP.NET 2.0 Global.asax Application_Start
  • 67.
    • AjaxHelper Teddy Ajax prototype Ajax ASP.NET UserControl Ajax ASP.NET 2.0 Teddy AjaxHelper NBear ASP.NET 2.0 Callback prototype NBear AjaxHelper AjaxDemo.aspx AjaxDemo2.aspx Page Ajax NBear AjaxHelper Ajax F5
  • 68.
      • ORM
      • IoC
      • NBear.Web
      • NBearLite
  • 69.
    • NBearLite .NET 2.0 (BSD ) SQL Server Oracle MS Access MySQL SQLite PostgreSQL NBearLite LINQ ( CRUD GroupBy InnerJoin Paging SubQuery ) NBearLite .NET SQL Server Oracle MySQL PostgreSQL
    • NBearLite ORM NBearLite Scalar/DataSet/IDataReader ADO.NET
    • NBearLite NBearMapping IDataReader/DataRow .NET ( ) .NET .NET
  • 70.
    • Visual Studio 2005 Web NBearLite SQL Server 2000 Northwind WinForm WinForm App.config Web Web.config
  • 71.
    • VS2005 Website Website App_Code
    • Default.aspx GridView1 GridView GridView2 GridView
  • 72.
    • Web.config ( ConnectionString ) SQL Server
  • 73.
    • Website NBearLite.dll ( zip dist ) dll NBearLite
  • 74.
    • QueryColumnsGenerator.exe ( zip dist )
    • Connection String Server=(local);Database=Northwind;Uid=sa;Pwd=sa ( SQL Server ) Root Class Name Northwind
    • Connect
    • CheckBox
    • C#
    • Generate Code output C#
    • Save Output As Website App_Code Northwind.cs
  • 75.
    • Website App_Code Northwind.cs
    • Website NBearLite.dll
  • 76.
    • Default.aspx.cs using
    • using NBearLite; // NBearLite
    • using QueryColumns; // 4 Output Namespace
    • Page_Load Database
    • Database db = new Database("Northwind");
  • 77.
    • Page_Load ( NBearLite )
    • GridView1.DataSource = db.Select(Northwind.Categories).ToDataSet().Tables[0]; // Categories
    • int ret = -1;
    • string outStr = "1";
    • GridView2.DataSource = Northwind.SalesByCategoryTest(db, out ret, "test1", "1997", ref outStr); //
  • 78.
  • 79.
  • 80.
      • ConfigurationEncrypter
      • EntityDesigns
      • EntityDesignToEntity
      • NBearVsPlugin
      • DbToEntityDesign
  • 81.
  • 82.
  • 83. Thank you!