NetProgrammingHelp.com

Asp.Net,C#,Ajax,Sql server,silverlight,Javascript codes exambles articles,Programming exambles

Recent Posts

  • How to declare/use global constants (enum’s) in javascript ajax function
  • Silverlight Data Binding OneWay TwoWay Asp.Net C# XAML
  • Accessing Executing Running Stored Procedure/Function/Package Using Linq Silverlight Xaml
  • Creating/Developing Silverlight Data Driven Applications Using Wcf Linq Asp.Net C#
  • Deploying Manually Publish XBAP Wpf Browser Application in IIS Asp.Net C# XAML
  • Creating Server and client using remoting asp.net c#
  • Create/Build wcf autocomplete/autoextender textbox using database linq c# asp.net
  • Essentials for Creating/Developing/Programming silverlight project tools wpf xaml
  • Working with xml data type variable sql server 2008 asp.net c#
  • Encrypting Stored Procedure sql server 2008 asp.net c#
  • -->

    sql server build-in functions aggregate functions asp.net c#

    Posted by James Add Comments

    Introduction:
    In this article,i am going to explain about how to effectively use/utilize the sql-server build in
    aggregate functions in t-sql code.

    Main:
    Aggregate Functions

    Aggregate functions:- are used to perform a calculation on one or more values, resulting in a single value.
    An example of a commonly used aggregate function is SUM, which is used to return the total value of a set
    of numeric values.

    AVG:-The AVG aggregate function calculates the average of non-NULL values in a group.

    CHECKSUM_AGG:-The CHECKSUM_AGG function returns a checksum value based on a group of rows, allowing you to
    potentially track changes to a table. For example, adding a new row or changing the value of a column that
    is being aggregated will usually result in a new checksum integer value. The reason why I say “usually” is
    that there is a possibility that the checksum value does not change even if values are modified.

    COUNT:-The COUNT aggregate function returns an integer data type showing the count of rows in a group.

    COUNT_BIG:-The COUNT_BIG function works the same as COUNT, only it returns a bigint data type value.

    GROUPING:-The GROUPING function returns 1 (True)or 0 (False) depending on whether a NULL value is due
    to a CUBE, ROLLUP, or GROUPING SETS operation. If False, the column expression NULL value is from the
    natural data. See Chapter 1′s recipe “Revealing Rows Generated by GROUPING.”

    MAX:-The MAX aggregate function returns the highest value in a set of non-NULL values.

    MIN:-The MIN aggregate function returns the lowest value in a group of non-NULL values.

    SUM:-The SUM aggregate function returns the summation of all non-NULL values in an expression.

    STDEV:-The STDEV function returns the standard deviation of all values provided in the expression based
    on a sample of the data population.

    STDEVP:-The STDEVP function also returns the standard deviation for all values in the provided expression,
    only it evaluates the entire data population.

    VAR:-The VAR function returns the statistical variance of values in an expression based on a sample of the
    provided population.

    VARP:-The VARP function also returns the variance of the provided values for the entire data population of
    the expression.

    Returning the Average of Values:-
    The AVG aggregate function calculates the average of non-NULL values in a group. For example:

    -- Average Product Review by Product
    SELECT ProductID,
          AVG(Rating) AvgRating
    FROM Production.ProductReview
    GROUP BY ProductID

    Returning ROW COUNT:-

    SELECT  Shelf,
          COUNT(ProductID) ProductCount
    FROM  Production.ProductInventory
    GROUP BY Shelf
    ORDER BY Shelf

    Min and Max:

    SELECT  MIN(Rating) MinRating,
          MAX(Rating) MaxRating
    FROM  Production.ProductReview

    Returning Sum of the values,

    SELECT  AccountNumber,
          SUM(TotalDue) TotalDueBySalesOrderID
    FROM Sales.SalesOrderHeader
    GROUP BY AccountNumber
    ORDER BY AccountNumber

    Using Statistical Aggregate Functions

    In this recipe, I’ll demonstrate using the statistical functions VAR, VARP, STDEV, and STDEVP.

    The VAR function returns the statistical variance of values in an expression based on a sample of the provided population
    (the VARP function also returns the variance of the provided values for the entire data population of the expression).

    This first example returns the statistical variance of the TaxAmt value for all rows in the Sales.SalesOrderHeader table:

    SELECT  VAR(TaxAmt) Variance_Sample,
          VARP(TaxAmt) Variance_EntirePopulation
    FROM Sales.SalesOrderHeader

    Conclusion:
    Hope this helps,
    Happy coding.

    Working with sql server view regular indexed distributed partitioned view asp.net c#

    Posted by James 4 Comments

    Introduction:
    In this article, i am going to explain about how to effectively use reular view,indexed view and
    distributed partitioned view.

    Main:
    Views allow you to create a virtual representation of table data defined by a SELECT statement.
    The defining SELECT statement can join one or more tables and can include one or more columns.
    Once created, a view can be referenced in the FROM clause of a query,

    Regular view –
    This view is defined by a Transact-SQL query. No data is actually stored in the database, only the view definition.

    Indexed view –
    This view is first defined by a Transact-SQL query, and then, after certain requirements are met, a clustered index
    is created on it in order to materialize the index data similar to table data. Once a clustered index is created,
    multiple nonclustered indexes can be created on the indexed view as needed.

    Distributed partitioned view –

    This is a view that uses UNION ALL to combine multiple, smaller tables separated across two or more SQL
    Server instances into a single, virtual table for performance purposes and scalability (expansion of table size on each
    SQL Server instance, for example).

    Regular view:

    CREATE VIEW [ schema_name . ] view_name [ (column [ ,...n ] ) ]
    [ WITH [ ENCRYPTION ] [ SCHEMABINDING ] [ VIEW_METADATA ] [ ,...n ] ]
    AS select_statement
    [ WITH CHECK OPTION ]
     
    USE NetProgrammingHelp
    GO
     
    CREATE VIEW dbo.v_Product_TransactionHistory
    AS
     
    SELECT   p.Name ProductName,
          p.ProductNumber,
          c.Name ProductCategory,
          s.Name ProductSubCategory,
          m.Name ProductModel,
          t.TransactionID,
          t.ReferenceOrderID,
          t.ReferenceOrderLineID,
          t.TransactionDate,
          t.TransactionType,
          t.Quantity,
          t.ActualCost
    FROM Production.TransactionHistory t
    INNER JOIN Production.Product p ON
       t.ProductID = p.ProductID
    INNER JOIN Production.ProductModel m ON
       m.ProductModelID = p.ProductModelID
    INNER JOIN Production.ProductSubcategory s ON
       s.ProductSubcategoryID = p.ProductSubcategoryID
    INNER JOIN Production.ProductCategory c ON
       c.ProductCategoryID = s.ProductCategoryID
    WHERE c.Name = 'Bikes'
    GO

    Displaying views and their structures in current database,

    SELECT   s.name SchemaName,
          v.name ViewName
    FROM sys.views v
    INNER JOIN sys.schemas s ON
       v.schema_id = s.schema_id
    ORDER BY s.name,
           v.name

    Encrypting a view,

    CREATE VIEW dbo.v_Product_TopTenListPrice
    WITH ENCRYPTION
    AS
     
    SELECT   TOP 10
          p.Name,
          p.ProductNumber,
          p.ListPrice
    FROM Production.Product p
    ORDER BY p.ListPrice DESC
    GO

    Indexed views,

    CREATE VIEW dbo.v_Product_Sales_By_LineTotal
    WITH SCHEMABINDING
    AS
     
    SELECT p.ProductID, p.Name ProductName,
           SUM(LineTotal) LineTotalByProduct,
           COUNT_BIG(*) LineItems
    FROM Sales.SalesOrderDetail s
    INNER JOIN Production.Product p ON
     
       s.ProductID = p.ProductID
    GROUP BY p.ProductID, p.Name
     
    GO

    Partitioned views,

    CREATE VIEW dbo.v_WebHits AS
      SELECT WebHitID,
           WebSite,
           HitDT
      FROM TSQLRecipeTest.dbo.WebHits_MegaCorp
    UNION ALL
      SELECT WebHitID,
           WebSite,
           HitDT
      FROM JOEPROD.TSQLRecipeTest.dbo.WebHits_MiniCorp
    GO

    Conclusion:
    Hope this helps,
    Happy coding.

    UI element property binding wpf dependency property asp.net c#

    Posted by James 2 Comments

    Introduction:
    In this article i am going to explain about how to create ui element property binding (Dependency property) in wpf.

    Main:
    The System.Windows.Data.Binding namespace creates a relationship between two properties: a binding source and a
    binding target. In this case, the target is the property of the element with the value you want to set. The source
    is the property of the element you want to get the value from. The target property must be a System.Windows.DependencyProperty, is designed to support data binding.

    In the XAML for the property you want to set, declare a Binding statement inside curly braces. Set the ElementName
    attribute to the name of the element to use as the binding source object. Set the Path attribute to the property on the source where the data should come from.

    for ex,

    <Window x:Class="Dependpropdemo.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <StackPanel>
            <Slider Name="slider"
                    Margin="4" Interval="1"
                    TickFrequency="1"
     
                    IsSnapToTickEnabled="True"
                    Minimum="0" Maximum="100"/>
            <StackPanel Orientation="Horizontal" >
                <TextBlock Width="Auto" HorizontalAlignment="Left" Margin="4"
                           Text="The value property of the slider is:" />
                <TextBlock Width="40" HorizontalAlignment="Center" Margin="4"
                           Text="{Binding
                                  ElementName=slider,
                                  Path=Value}" />
            </StackPanel>
        </StackPanel>
    </Window>

    1

    2

    Conclusion:
    Hope this helps,
    Happy coding.

    Exception Handling WCF Programming/Services Fault Exception Asp.Net c#

    Posted by James 7 Comments

    Introduction:
    In this article,i am going to explain about how to handling exceptions in wcf services using fault exception.

    Main:

    Fault Handling in WCF:
    The default behavior for WCF is not to return that exception to the client unless it is thrown as a FaultException
    (or inherited subtype) or if a FaultContract is implemented.

    See this below simple examble,

    Service Code:

    using System.Data;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.ServiceModel;
    using System.Runtime.Serialization;
     
    using System.Threading;
     
    using System.Security;
    using System.Security.Permissions;
    using System.Security.Principal;
     
    namespace Products
    {
        // Simplified service contract
        [ServiceContract(Namespace = "http://NetProgrammingHelp.com/2006/09/30", Name = "SimpleProductsService")]
        public interface ISimpleProductsService
        {
            [OperationContract(Name = "ListProducts")]
            List<string> ListProducts();
        }
     
     
        // WCF service class that implements the service contract
        public class ProductsServiceImpl : ISimpleProductsService
        {
            public List<string> ListProducts()
            {
                // Read the configuration information for connecting to the NetPrgHlp database
                Database dbNetPrgHlp;
                try
                {
                    dbNetPrgHlp = DatabaseFactory.CreateDatabase("NetPrgHlpConnection");
                }
                catch (Exception e)
                {
                    throw new FaultException("Exception reading configuration information for the NetPrgHlp database: " + e.Message, new FaultCode("CreateDatabase"));
                }
     
                // Retrieve the details of all products by using a DataReader
                IDataReader productsReader;
                try
                {
                    string queryString = @"SELECT ProductNumber 
                                           FROM Production.Product";
                    productsReader = dbNetPrgHlp.ExecuteReader(CommandType.Text, queryString);
                }
                catch (Exception e)
                {
                    throw new FaultException("Exception querying the NetPrgHlp database: " + e.Message, new FaultCode("ExecuteReader"));
                }
     
                // Create and populate a list of products
                List<string> productsList = new List<string>();
                try
                {
     
                    while (productsReader.Read())
                    {
                        string productNumber = productsReader.GetString(0);
                        productsList.Add(productNumber);
                    }
                }
                catch (Exception e)
                {
                    throw new FaultException("Exception reading product numbers: " + e.Message, new FaultCode("Read/GetString"));
                }
     
                //Return the list of products
                return productsList;
            }
        }
    }

    Client Code:

    using System.ServiceModel;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.ServiceModel.Channels;
     
    namespace ProductsClient
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Press ENTER when the service has started");
                Console.ReadLine();
     
                try
                {
                    // Create a default HTTP binding
                    BasicHttpBinding httpBinding = new BasicHttpBinding();
     
                    // Create an endpoint
                    EndpointAddress address = new EndpointAddress(
                        "http://localhost:8040/SimpleProductsService/SimpleProductsService.svc");
     
                    IChannelFactory<IRequestChannel> factory =
                        httpBinding.BuildChannelFactory<IRequestChannel>();
                    factory.Open();
     
                    IRequestChannel channel = factory.CreateChannel(address);
                    channel.Open();
     
                    Message request = Message.CreateMessage(MessageVersion.Soap11,
                        "http://NetPrgHlp.com/2006/09/30/SimpleProductsService/ListProducts");
     
                    Message reply = channel.Request(request);
                    Console.Out.WriteLine(reply);
     
                    request.Close();
                    reply.Close();
                    channel.Close();
                    factory.Close();
                }
     
                catch (Exception e)
                {
                    Console.WriteLine("Exception: {0}", e.Message);
                }
     
                Console.WriteLine("Press ENTER to finish");
                Console.ReadLine();
            }
        }
    }

    Conclusion:
    Hope this helps,
    Happy coding.

    creating/first asp.net mvc web application c# asp.net model view pattern

    Posted by James 10 Comments

    Introduction:
    In this article, i am going explain about how to create a asp.net mvc web application using asp.net.

    Main:
    For creating asp.net mvc web application please goto file –> new –> project and select asp.net
    mvc2 template,
    mvc1

    After clicking on OK, Visual Studio will ask you if you want to create a test project. This dialog
    offers the choice between several unit testing frameworks that can be used for testing your ASP.NET
    MVC application.
    mvc23
    You can decide for yourself if you want to create a unit testing project right now—you can also add
    a testing project later on. Letting the ASP.NET MVC project template create a test project now is
    convenient because it creates all of the project references, and contains an example unit test, although
    this is not required. For this example, continue by adding the default unit test project.
    mvc3

    After the ASP.NET MVC project has been created, you will notice a default folder structure. There’s a
    Controllers folder, a Models folder, a Views folder, as well as a Content folder and a Scripts folder.
    ASP.NET MVC comes with the convention that these folders (and namespaces) are used for locating the
    different blocks used for building the ASP.NET MVC framework. The Controllers folder obviously contains
    all of the controller classes; the Models folder contains the model classes; while the Views folder contains
    the view pages. Content will typically contain web site content such as images and stylesheet files, and
    Scripts will contain all of the JavaScript files used by the web application. By default, the Scripts folder
    contains some JavaScript files required for the use of Microsoft AJAX or jQuery.

    see this below demonstration,

    Allready we discussed view is just used html resources,so just add a new webpage under view and named it
    welcome.aspx,

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WelCome.aspx.cs"  Inherits="System.Web.Mvc.ViewPage" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <asp:Content ID="Content1"
         ContentPlaceHolderID="MainContent"
         runat="server">
     
          <h1><%=ViewData["Welcomestring"]%></h1>
     
        </asp:Content>
     
        </div>
        </form>
    </body>
    </html>

    here we are just trying to display welcome string using viewstate,

    We allready discussed all business logic’s are coming under model,here we are returning a simple welcome string,so
    i just added the properties for that welcomestring,
    mvc4
    <

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
     
    namespace mvcdemo.Models
    {
        public class WelcomeString : Controller
        {
            //
            // GET: /WelcomeString/
            public class welcomestr
            {              
     
                //return View("Welcome to MVC,its really very easy and cool");
                public string Getstring { get; set; }
            }        
     
        }
    }

    next we need to create a controller for working with the html page,

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using mvcdemo.Models;
     
    namespace mvcdemo.Controllers
    {
        public class WelcomeController : Controller
        {
            //
            // GET: /Welcome/
     
            public ActionResult Index()
            {
                WelcomeString.welcomestr objwel = new WelcomeString.welcomestr();
                objwel.Getstring = "Welcome to MVC,its really very easy and cool";
     
                ViewData["Welcomestring"] = objwel.Getstring;
                return View();
            }
     
        }
    }

    thatsit!

    Conclusion:
    Hope this simple program helps you to understand about MVC,
    Happy coding.

    Overview of MVC architecture MVC advantages and using in asp.net c#

    Posted by James 2 Comments

    Introduction:
    In this article,i am going explain about the architecture of model-view-pattern,
    and how we can use this pattern in asp.net applications.

    Main:

    Why MVC?

    Model-view-controller, or MVC in short, is a design pattern used in software engineering.
    The main purpose of this design pattern is to isolate business logic from the user interface,
    in order to focus on better maintainability, testability, and a cleaner structure to the application.

    The MVC pattern consists of three key parts: the model, the controller, and the view.

    Model

    The model consists of some encapsulated data along with its processing logic, and is
    isolated from the manipulation logic, which is encapsulated in the controller. The presentation logic
    is located in the view component.

    The model object knows all of the data that needs to be displayed. It can also define some operations
    that manipulate this encapsulated data. It knows absolutely nothing about the graphical user interface—it
    has no clue about how to display data or respond to actions that occur in the GUI. An example of a model
    would be a calculator. A calculator contains data (a numeric value), some methods to manipulate this data
    (add, subtract, multiply, and divide), and a method to retrieve the current value from this model.

    View

    The view object refers to the model. It uses read-only methods of the model to query and retrieve data.
    It can look like an HTML page, a Windows GUI, or even the LED display of a physical calculator. In our
    example of the calculator, the view is the display of the calculator, which receives model data (the
    current calculation result) from the controller.

    Controller

    The controller object is the interaction glue of the model and the view. It knows that
    the model expects actions such as add, subtract, multiply, and divide, and also knows that the GUI will
    send some events that may require these operations to be called. In the calculator example, clicking on
    the “+” button on the view will trigger the controller to call the add method on the model and re-render
    the view with the data updated if necessary.

    we can say controler simply controlling the user actions,

    mvc
    Main Advantages while comparing asp.net web forms,

    Complexity of application logic is made easier to manage because of the separation of an application into model, view, and controller.

    It allows for easier parallel development; each developer can work on a separate component of the MVC pattern.

    It provides good support for TDD, mocking, and unit testing frameworks. TDD enables you to write tests for an application first,
    after which the application logic is developed. TDD, mocking, and unit testing,

    It does not use ViewState or server-based forms, which allows you to have full control over the application’s behavior and HTML markup.

    It uses RESTful interfaces for URLs, which is better for SEO (Search Engine Optimization). REST is short for REpresentational State Transfer—the concept of using URLs as the link to a resource, which can be a controller action method, rather than to physical files on the web server.

    A typical page size is small, because no unnecessary data is transferred in the form of hidden ViewState data.

    It integrates easily with client-side JavaScript frameworks such as jQuery or ExtJS.

    Conclusion:
    Hope this helps,
    Happy coding.

    creating menus using xaml wpf asp.net c# silverlight navigation

    Posted by James 2 Comments

    Introduction:
    In this article,i am going to explain about how to create menus/navigation using xaml menu element.

    Main:
    See the below demo using menu element,

    <Window x:Class="NetProgrammingHelp.menu"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="ControlDemos" Height="300" Width="300"
        >
        <Grid>
          <Menu Width="30" Margin="10, 10, 5, 5" HorizontalAlignment="Left" Background="White">
            <MenuItem Header="_File">
              <MenuItem Header="_New" IsCheckable="true"/>
              <MenuItem Header="_Open" IsCheckable="true"/>
              <MenuItem Header="_Close" IsCheckable="true"/>
              <Separator/>
              <MenuItem Header="Open Previous">
                <MenuItem Header="Word Documents" />
                <MenuItem Header="Source Code" >
                  <MenuItem Header="C# Files" />
                </MenuItem>
              </MenuItem>
              <Separator/>
              <MenuItem Header="E_xit">
     
              </MenuItem>
            </MenuItem>
          </Menu>
     
          <Image VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1" Margin="41,59.4453125,0,0" Width="84" Height="56.109375" Name="image1" Source="file:///c:/avchap6/ControlDemos/ControlDemos/Fishtn.jpg#Fishtn.jpg">
            <Image.ContextMenu>
              <ContextMenu>
                <MenuItem Header="CheckStates">
                  <MenuItem Header="Is Checkable And Is Checked" IsCheckable="True" IsChecked="True" Name="mnuItem1" ></MenuItem>
                  <MenuItem Header="Is Checkable But Is Not Checked" IsCheckable="True" IsChecked="False"></MenuItem>
                  <MenuItem Header="Is Not Checkable And Is Not Checked" IsCheckable="False" IsChecked="False"></MenuItem>
                  <MenuItem Header="Is Not Checkable But I Set The IsChecked Property" IsCheckable="False" IsChecked="True">
                    <MenuItem.ToolTip>
                      <StackPanel Orientation="Horizontal">
                        <Image Source="c:Fish.jpg"></Image>
                        <Label>Here is my stackpanel picture tooltip, wierd, huh?</Label>
                      </StackPanel>
                    </MenuItem.ToolTip>
                  </MenuItem>
                </MenuItem>
              </ContextMenu>
            </Image.ContextMenu>
          </Image>
      </Grid>
    </Window>

    32
    conclusion:
    Hope this helps,
    Happy coding.

    Using accessing performing coding plinq in asp.net c# linq performance improvements

    Posted by James 9 Comments

    Introduction:
    In this article,i am going to explain about how to use PLINQ to parallelize declarative data access in asp.net linq application.

    Main:
    What is plinq?
    plinq is nothing but spliting the normal linq process into several partitions,and then using tasks to retrieve the data that
    matches the criteria specified by the query for each partition in parallel. The results retrieved for each partition are
    combined into a single enumerable result set when the tasks have completed. PLINQ is ideal for scenarios that involve data
    sets with large numbers of elements, or if the criteria specified for matching data involve complex, expensive operations.

    For achieve this,we has a enumerable method named AsParellel(),pling is especially helps us to improve linq application
    performance,

    See the below simple ex,create one console application,and try the below codes,you can felt the performance is quite better while using AsParallel() method,

    Without AsParallel(),

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
     
    namespace plingdemo
    {
        class Program
        {
            static void Main(string[] args)
            {
                DataClasses1DataContext sqlcontext = new DataClasses1DataContext();
     
                //normal linq
                try
                {
                    var Emps = from p in sqlcontext.Emps
                               join x in sqlcontext.depts
                               on p.Deptid equals x.dept_id
                               select p;
     
                    Console.WriteLine(Emps);
                    Console.ReadLine();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
     
     
     
     
     
            }
        }
    }

    22
    With Parallel,

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
     
    namespace plingdemo
    {
        class Program
        {
            static void Main(string[] args)
            {
                DataClasses1DataContext sqlcontext = new DataClasses1DataContext();
     
                //normal linq
                try
                {
                    var Emps = from p in sqlcontext.Emps.AsParallel()
                               join x in sqlcontext.depts.AsParallel()
                               on p.Deptid equals x.dept_id
                               select p;
     
                    Console.WriteLine(Emps);
                    Console.ReadLine();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
     
     
     
     
     
            }
        }
    }

    15
    We will do the enhancemens in pling in next article,

    Conclusion:
    Hope this helps,
    Happy Coding.

    Generating Using Performing ADO.NET entity data model using asp.net c# entity framework linq

    Posted by James 4 Comments

    Introduction:
    In this article,i am going to explain about how to use ado.net entity data model against sqldatabase in asp.net
    application.

    Main:

    What is ado.net entity data model?

    The Entity Data Model is an Entity-Relationship data model.(Its similar to linq to sql data class),

    ADO.NET Entity Framework abstracts the relational (logical) schema of the data that is stored in a database and presents its conceptual schema to the application. For example, in the database, entries about a customer and their information can be stored in the Customers table, their orders in the Orders table and their contact information in yet another Contacts table. For an application to deal with this database, it has to know which information is in which table, i.e., the relational schema of the data is hard-coded into the application.

    The disadvantage of this approach is that if this schema is changed the application is not shielded from the change. Also, the application has to perform SQL joins to traverse the relationships of the data elements in order to find related data. For example, to find the orders of a certain customer, the customer needs to be selected from the Customers table, the Customers table needs to be joined with the Orders table, and the joined tables need to be queried for the orders that are linked to the customer.

    This model of traversing relationships between items is very different from the model used in object-oriented programming languages, where the relationships of an object’s features are exposed as Properties of the object and accessing the property traverses the relationship. Also, using SQL queries expressed as strings, only to have it processed by the database, keeps the programming language from making any guarantees about the operation and from providing compile time type information.

    The mapping of logical schema into the physical schema that defines how the data is structured and stored on the disk is the job of the database system and client side data access mechanisms are shielded from it as the database exposes the data in the way specified by its logical schema.

    How to use ado.net data entity model in asp.net application?

    14

    21

    3

    4

    5

    6

    81

    71

    We can easily access the entity model like linq to sql,

      masterEntities masterContext = new masterEntities();
     
                var EmpNames = from p in masterContext.Emps
                                   select p.FirstName;
     
                foreach (var name in EmpNames)
                {
                    MessageBox.Show (string.Format( "Employee name: {0}", name));
                }

    Conclusion:
    Hope this helps,
    Happy Coding

    run/expose/host a COM+ application as a wcf service asp.net c# wcf vb

    Posted by James one Commented

    Introduction:
    In this article,i am going to explain how to run a com+ application as a wcf service.

    Main:
    The wcf system.servicemodel namespace helps us to run com+ services as wcf application.

    We can convert the com+ component as service,
    com+ component interfaces as contracts,
    com+ component methods as service operations,

    See this below demo application,In this application i am going to explore com+ app as wcf service.(See the pics below),
    addcomapp2

    Click Next,
    app12

    Browse it and select the app you wants to install as COM+ service,
    app21
    Next we need to create a wrapper for exposing this com+ service as wcf,

    The primary utility for this is the ComSvcConfig.exe utility. This is a command-line utility
    that is installed with the .NET 3.0 runtime. Additionally, the SvcConfigEditor.exe utility
    provides a graphical interface with some additional features that help hide the complexities of
    the command-line ComSvcConfig.exe utility. One suggestion is to get used to the SvcConfigEditor.exe
    utility; it facilitates the composition of proper configuration files for WCF with configuration-time
    validation of many elements.

    We can ComSvcConfig utiliy in the following two ways,

    1.Command Line,
    2.Service Configuration Editor GUI

    In command line,(for ex)

    ComSvcConfig.exe /install /application:COMSVCS /contract:COMSVCS.TrackerServer,IGetAppData /hosting:comservice

    In GUI,(You must be an admin for access this tool)

    Just Goto Start –> Programs –> Microsoft visual studio –> Microsoft windows SDK tools –> click service
    configuration editor,
    svc14
    New let’s start to configure,

    1.Click File –> Integrate –> COM+ Application,
    integ12

    2.Select the interface you wants to expose as a wcf contracts,

    11

    2

    thatsit,

    Conclusion:
    Hope this helps,
    Happy coding.

    Software