Sudheer Kumar

ASP.Net, C#, BizTalk, MSBuild, WPF, WCF, WF....
posts - 28, comments - 110, trackbacks - 16

My Links

News



Archives

Post Categories

Tuesday, September 07, 2010

.Net 4.0

C #4.0 has been here for a while and it has got many interesting features.

1. dynamic keyword:

It represents an object that will be resolved at run time. For example, assume that you have 2 different classes that have the same signature.

Then you can have a method like this.

private void TestMethod(object myObject)

{

string name = myObject.Name;

string address = myObjec.Address;

}

Now you can pass any object that has the same interface to the TestMethod(). This is some thing which is not possible with a base class.

dynamic has got much more power and more about that later.

2. Parallel Processing:

- PLINQ: Helps to execute a LINQ query that will be parallel processed

return mySearch.AsParallel().Where(x => myCustomFilter(x));

- Parallel Library:

Parallel.For(0; 10000; delegate(int index))
{

//some complex operation

});

more on these topics later…

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Tuesday, September 07, 2010 5:00 AM | Feedback (0) |

Tuesday, April 20, 2010

Reusing WCF Proxy to reduce Memory Usage

I am working on a program that uploads BLOB from DB to a Document Management System.

I have a WCF service to interact with the DMS.

I have a multi-threaded client program that uploads the BLOBs to DMS and every thread used to create and dispose a proxy instance for every record to update.

When I have a large no of records to convert, I found that the tool’s memory foot print keeps increasing. After a little debugging I found that the WCF proxies are the culprits for excessive memory usage.

I changed the program to re-use the proxies to the service, having one proxy per thread.

So in some scenarios, it might be beneficial to re-use WCF proxies.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Tuesday, April 20, 2010 8:38 AM | Feedback (0) |

Sunday, April 11, 2010

Entity Framework & Transactions

 

There are many instances we might have to use transactions to maintain data consistency.

With Entity Framework, it is a little different conceptually.

Case 1 – Transaction b/w multiple SaveChanges():

here if you just use a transaction scope, then Entity Framework (EF) will use distributed transactions instead of local transactions. The reason is that, EF closes and opens the connection when ever required only, which means, it used 2 different connections for different SaveChanges() calls.

To resolve this, use the following method. Here we are opening a connection explicitly so as not to span across multipel connections.

 

using (TransactionScope ts = new TransactionScope())
{
    context.Connection.Open();

    //Operation1 : context.SaveChanges();

    //Operation2 :  context.SaveChanges()

    //At the end close the connection

    ts.Complete();

}

catch (Exception ex)

{

      //Handle Exception

}

finally
{
      if (context.Connection.State == ConnectionState.Open)
      {
           context.Connection.Close();
      }
}

 

Case 2 – Transaction between DB & Non-DB operations:

For example, assume that you have a table that keeps track of Emails to be sent.

Here you want to update certain details like DataSent once if the mail was successfully sent by the e-mail client.

Email eml = GetEmailToSend();

eml.DateSent = DateTime.Now;

using (TransactionScope ts = new TransactionScope())
{

   //Update DB

   context.saveChanges();

  //if update is successful, send the email using smtp client

  smtpClient.Send();

  //if send was successful, then commit

  ts.Complete();

}

 

Here since you are dealing with a single context.SaveChanges(), you just need to use the TransactionScope, just before saving the context only.

 

Hope this was helpful!

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Sunday, April 11, 2010 9:57 AM | Feedback (1) |

Thursday, September 24, 2009

Windows Live Writer

I recently found that I can use Windows Live Writer to connect to my blog on GWB.

It has a nice editor, can add images and tables easily, save as draft and publish later etc.

Happy Blogging.!

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Thursday, September 24, 2009 7:04 PM | Feedback (0) |

Tuesday, September 01, 2009

WCF Proxy Close Issue

WCF Proxy need to be closed explicitly and if you are using the using() statement, you have the possibility of loosing the original exception.
You can find details about this issue in the following posts.
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/b95b91c7-d498-446c-b38f-ef132989c154
http://geekswithblogs.net/marcel/archive/2007/05/01/112159.aspx

Marc Gravell presented a great idea to have a wrapper so as to overcome this issue.
http://marcgravell.blogspot.com/2008/11/dontdontuse-using.html

But that will work only with the proxies got using Service reference.
What if you are getting your service proxy using : factory.CreateChannel().
This blog is about the solution for that.

Here is the full code for the proxy.

public interface IDisposableWrapper<T> : IDisposable
    {
        T BaseObject { get; }
    }
    public class DisposableWrapper<T> : IDisposableWrapper<T> where T : class
    {
        public T BaseObject { get; private set; }
        public DisposableWrapper(T baseObject) { BaseObject = baseObject; }
        protected virtual void OnDispose()
        {
            (BaseObject as IDisposable).Dispose();
        }
        public void Dispose()
        {
            if (BaseObject != null)
            {
                try
                {
                    OnDispose();
                }
                catch (Exception ex){
                    //Log if required
                }
            }
            BaseObject = default(T);
        }
    }

    public class ClientWrapper<TProxy> : DisposableWrapper<TProxy>
        where TProxy : class
    {
        public ClientWrapper(TProxy proxy) : base(proxy) { }
        protected override void OnDispose()
        {
            if ((this.BaseObject as IClientChannel).State == CommunicationState.Faulted)
            {
                (this.BaseObject as IClientChannel).Abort();
            }
            else
            {
               
                (this.BaseObject as IClientChannel).Close();
            }
           
        }
    }

    public static class WCFExtensions
    {
        public static IDisposableWrapper<TProxy> Wrap<TProxy>(
            this TProxy proxy)
            where TProxy : class
        {

            return new ClientWrapper<TProxy>(proxy);
        }
    }


Client Code:
ChannelFactory<IService1> factory = new ChannelFactory<IService1>(new WSHttpBinding(), new EndpointAddress("http://localhost:8731/TestWcfServiceLibrary/Service1/"));
            IService1 proxy = factory.CreateChannel();

using (var proxy = proxy.Wrap<IService>())
                {
                    //Call the methods  the following wat
                    string s1 = proxy.BaseObject.GetData(10);
                }

Happy coding.!
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Tuesday, September 01, 2009 9:40 AM | Feedback (0) |

Thursday, June 11, 2009

Entity Framework Tips

1. Error Message : Only parameterless constructors and initializers are supported in LINQ to Entities:
 
The following query works perfetcly with LINQ:
NoticeRecipient rec = dc.NoticeRecipients.Where(o => o.RecipientID == new Guid(id)).FirstOrDefault<NoticeRecipient>();
 
But the same query will give the above mentioned error with Entity Framework.
The issue was using new Guid() inside lambda expressions. You have to change the query as follows.
 
Guid gID = new Guid(id);
NoticeRecipient rec = dc.NoticeRecipients.Where(o => o.RecipientID == gID).FirstOrDefault<NoticeRecipient>();
 
So take a note of C# expressions, while writing queries for EF.
 
See the list of methods that can be used in an expression as of now:
http://msdn.microsoft.com/en-us/library/bb738681.aspx

2. Left-Outer Join - 2 Styles:
 
a) You have the primary key on the table on left part of the Join
 
eg: You want to left outer join between Entity table and PostalAddress table.
Here PK is on Entity table.

            var v = from en in context.Entity
                    let leftouter = (from pa in en.PostalAddress
                                     select new
                                     {
                                         pa.PostalAddressID
                                     }).FirstOrDefault()
                    select new
                    {
                        EntityID = en.EntityID,
                        PostalAddressID = (Guid?)leftouter.PostalAddressID,
                    };
 
 
b) You have the primary key on the table on the right part of the Join:
eg:You want to do left outer join b/w NoitceRecipient table and NoitceStatus table. Here NoticeRecipient contains a FK and NoticeStatus has the PK.

        var v = from nr in context.NoticeRecipient
                    let lo1 = (from ns in context.NoticeStatus
                                     where ns.NoticeStatusID == nr.NoticeStatus.NoticeStatusID
                                      select new { ns.StatusText }).FirstOrDefault()
                    select new {nr.NoticeRecipientID, lo1.StatusText};
                    
 
3. Include("TableRelation"):
Include will eager load all the columns in the table mentioned after doing a "LEFT OUTER" join based on the key fields relationship between 2 tables.
Note that it is not an INNER JOIN but causes a LEFT OUTER JOIN.
But if you do GROUP BY in your query, the Inlcude() option will be ignored.

eg: Get Entity and PostalAddresses using Include

var v = from en in context.Entity.Include("PostalAddress")
            select new {en.EntityID, en.PostalAddress.PostalAddressID}
 
NOTE: Through Include(), you are not including a table, but only one of the relationships of a table.
See this:
http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/9f8e82c8-e3a6-46d2-b6b3-e8338b46fb57


4. EF cannot do left outer join if there is no relationship:
Not very common, but there are cases where you might choose to store data w/o a relationship.
EF can't do a Left Outer Join in that case (neither include or let will work)
You can use LINQ-SQL in those scenarios.
5. Implementing SQL IN:
EF cannot JOIN with a List<T> or doesn't support using : Contains() as can be done in LINQ-SQL.
Alternative us to build an lambda expression equivalent to IN.
eg:
 var grpNoticeRecipients = (from nr in ctx.NoticeRecipient.Where(
                                             EntityFrameworkUtils.BuildContainsExpression<NoticeRecipient, Guid>(e =>  e.NoticeRecipientID, noticeRecipientIDList))
                                       where nr.EmailAddress.EmailAddressID != null
                                      select nr).GroupBy(o => o.EmailAddress.EmailAddressID);
See more details on this post:
http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/095745fe-dcf0-4142-b684-b7e4a1ab59f0

6. GROUP BY:
Note that Include() doesn't work with GroupBy
 
 
 
Also see this excellent blog.
 
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Thursday, June 11, 2009 1:22 PM | Feedback (5) |

Wednesday, June 03, 2009

Think MANY TIMES before choosing Entity Framework

If you are planning to choose Linq to Entities data model for you projects, please read-on.

Linq-Entities (LE) still doesn't have many of the features that are present in LINQ-Sql (LS). The following are the major things which came across during m development.

This article assumes that you are familiar with both.

 

  1. LE doesn’t have proper support for Stored Procedures (SP):

LS can import a PS to DBML file or using SqlMetal and can invoke it directly from the context and during import a type is automatically defined for the return data from the SP.

 With EF, you cannot invoke the SP on the data context as used to be with LINQ.

You can do it using an extension provided EFExtensions:

http://blogs.msdn.com/meek/archive/2008/03/26/ado-entity-framework-stored-procedure-customization.aspx

But MS doesn’t guarantee that it will be supported in future.

 

If you import SP using EDMGen.exe, you will be surprised to see that EDMGen has no switch that imports a Stored Procedure mapping to CSDL and MSL. That means you have to manually do the importing to CSDL and MSL files..!

  1. LS supports Outer Joins, but LE has crippled support for outer joins.

http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/a3f2b146-750b-435c-b48c-2ea301bf130f/

 

  1. LS can join with List<T> where are LE can’t do the same.
  2. LE doesn’t practically support the SQL IN clause:

http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/095745fe-dcf0-4142-b684-b7e4a1ab59f0/

 The work arounds are very messy.

         5. You can't use the extension methods like Any() in LE, but they work well in LS

Also see this blog:

http://www.kindblad.com/2009/01/11/why-you-should-not-use-the-adonet-entity-framework/

LE is a crippled solution in the sense that LE promotes using the Lambda expression for querying the database entities, but these Lambda expressions doesn’t support many basic SQL operations.

And there is no proper support for Stored Procedures.

LE is projected as a superior solution that LS, but LE doesn’t support many features of LS.

I have no words to express my frustrations..!

 

Update [06/08/2009]

Found a better solution to do left outer join with EF

http://oddiandeveloper.blogspot.com/2008/12/testable-left-outer-join-in-linq-to.html

 You can flatten a left-outer-join as follows:

 var v = from en in context.Entity.Include("PostalAddress").Include("PostalAddressType")
                    let leftouter = (from pa in en.PostalAddress
                                                                select new {
                                                                                      PA = pa,
                                                                                      PAT = pa.PostalAddressType
                                                                                     }).FirstOrDefault()
                    select new {
                        EntityID = en.EntityID,
                        PostalAddressID = (Guid?)leftouter.PA.PostalAddressID,
                        PostalTypeID = (Guid?)leftouter.PAT.PostalAddressTypeID
                    };


  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Wednesday, June 03, 2009 10:10 AM | Feedback (2) |

Tuesday, November 25, 2008

Dynamic LINQ

There are ways LINQ can query completely dynamically from Database.

I had requirement to get a column value of a table in a generic and dynamic manner for a given key value.

Here I pass the table type (LINQ type) and key value to retrieve other column values of the table in a totally dynamic manner.

private string GetColumnValue(DataContext dc, Type tableType, Type keyColumnType, string keyColumnName, object objectValue, string getColumnName)

        {

            string getColumnValue = null;

 

            IQueryable queryableData = dc.GetTable(tableType).AsQueryable();

 

            //Create an expression that gets specific property

            // tbl.Where (item => item.PropertyName == propertyValue)

            ParameterExpression pe = Expression.Parameter(tableType, "item");

            Expression left = Expression.Property(pe, tableType.GetProperty(keyColumnName));

 

            //Convert the key value to the respective type

            Expression right = Expression.Constant(Convert.ChangeType(objectValue, keyColumnType), keyColumnType);

            Expression e1 = Expression.Equal(left, right);

 

            MethodCallExpression whereCallExpression = Expression.Call(

                typeof(Queryable),

                "Where",

                new Type[] { queryableData.ElementType },

                queryableData.Expression,

                Expression.Lambda(e1, new ParameterExpression[] { pe }));

 

            // Create an executable query from the expression tree.

            IQueryable results = queryableData.Provider.CreateQuery<MediaRequest>(whereCallExpression);

            //NOTE: Onlye IQueryable<T> has methods like FirstOrDefault<T>().

            //So do a for..each to get the object in IQueryable.

            foreach (object o in results)

            {

                //Use reflection to get the value property value

                try

                {

                    getColumnValue = o.GetType().GetProperty(getColumnName).GetValue(o, null).ToString();

                    break;

                }

                catch (Exception ex)

                {

                    //Log the exception

                }

            }

            return getColumnValue;

        }

  Example and Usage:

MyDataContext mediaDB = new MyDataContext("Server=Server;Database=DB;Trusted_Connection=true");

            string tableTypeString = "Data.Request, Data"; //This is the full name of the LINQ class that corresponds to a data table

            Type tblType = Type.GetType(tableTypeString);

            string fileName = GetColumnValue(mediaDB, tblType, typeof(int), "RequestID", 1), "FileName");

            string ipAddress = GetColumnValue(mediaDB, tblType, typeof(int), "RequestID", 2, "IPAddress");

           

 Hope this helps..!


  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Tuesday, November 25, 2008 6:35 AM | Feedback (4) |

Monday, July 21, 2008

Error : This disc contains a "UDF" file system and requires an operating system that supports the ISO-13346 "UDF" file system specification.

I was trying to install VS 2008 on my laptop which has Windows media center XP SP2 on it.
I tried to open the ISO with Win Image and later with IZArc, bit in vain.
With a lot of searching, finally I got the solution that worked for me.

1. Install the UDF support for XP SP2 from:
     http://support.microsoft.com/kb/899527
    Install the download from the KB.  
 
2. Install Virtual CD-ROM Control Panel 2.0 from MS:
  Even after the first step, neither the WinImage nor the IZArc could read the ISO file.
  Then I installed the Virtual CD-ROM Control Panel from:
   http://www.softpedia.com/get/CD-DVD-Tools/Virtual-CD-DVD-Rom/Virtual-CDROM-Control-Panel.shtml
   Follow the instructions and mount your ISO using it..
   Thatz it.. :)
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, July 21, 2008 1:30 PM | Feedback (0) |

Monday, April 21, 2008

DLINQ

Long gap in blogging due to an ongoing release.
This time back with DLINQ.
Like the way LINQ to Objects work on Objects that implement IEnumerable, DLINQ works on Database objects.
If you want to know the basics of DLINQ, here are some of the links:

Basics:
http://blah.winsmarts.com/2006/06/02/demystifying-dlinq-part1--an-introduction-to-dlinq.aspx
DLINQ and Stored procedures:
http://weblogs.asp.net/scottgu/archive/2006/06/18/DLINQ-with-Stored-Procedures.aspx

Using DLINQ with ASP.NET:
http://weblogs.asp.net/scottgu/archive/2006/05/14/Using-LINQ-with-ASP.NET-_2800_Part-1_2900_.aspx
http://weblogs.asp.net/scottgu/archive/2006/06/04/Using-DLINQ-with-ASP.NET-_2800_Part-2-of-my-LINQ-series_2900_.aspx

Now, How to combine these ideas to create an application framework that makes the development easier and structured?
More about that later..
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, April 21, 2008 12:11 PM | Feedback (1) |

Friday, March 28, 2008

LINQ .. A powerful extension to .Net

The post assumes that you have basic under standing of LINQ.
The following section tries to give some deeper insight in to the technology.
A lot of examples can be found at 101 Linq Samples (http://msdn2.microsoft.com/en-us/vcsharp/aa336746.aspx)

1.    Language Integrated Query (LINQ):

a.      How does LINQ work?

                                                               i.      When you write an expression for DLINQ, the expression is converted to a set of DB commands. It then opens a connection to get data.

                                                             ii.      When you use LINQ to objects, it iterates through the items in the object and provides you the matches.

                                                            iii.      But the corresponding C# expression gets compiled when you compile the code.

                                                           iv.      So the main advantage is the easiness to loop though a variety of data sources and convenience of having cleaner code.

b. Uses deferred execution of Query expression, which means?

                                                               i.      LINQ executes the expression only when you iterate through the matches

                                                             ii.       LINQ executes the expression every time you iterate through the match collections.

     


c.       Usage Scenarios for LINQ to Objects:

                                                               i.      You can use standard .Net expression in the “Select” clause. Here you have a List<Employee> for example.

matches = from employee in employees
select employee.FirstName + employee.LastName;

                                                             ii.      You can create anonymous types in select expression.

var emps = from emp in arrEmps

select new {First=emp.FirstName, Last=emp.LastName };

                                foreach(var match in emps)

                                 {

                                               string strFullName = match.First + match.Last;

}

Note the usage of implicit types.

                                                            iii.      Can have multiple conditions in the where clause:

IEnumerable<Product> matches;
matches = from product in products
where product.UnitsInStock > 0 && product.UnitPrice > 3.00M

select product;

 

                                                           iv.      The where clause can even be a method call.

IEnumerable<EmployeeDetails> matches;

matches = from employee in employees

where TestEmployee(employee)

select employee;

                                                             v.      Can Sort using orderby clasue:

IEnumerable<EmployeeDetails> matches;

matches = from employee in employees

orderby employee.LastName, employee.FirstName

select employee;

                                                            vi.      You can use group by:

 var empGrp = from emp in arrEmps

                                                     group emp by emp.Age into g

                                                     select g.Key;          

                foreach (var item in empGrp)

                {

                                                 int j = item;  //Implicit conversion  here

                }

                But if you want to iterate through grouped items:

// Look through all the groups.

foreach (IGrouping<string, EmployeeDetails> group in matches)

{

// Loop through all the EmployeeDetails objects in the current group.

foreach (EmployeeDetails employee in group)

{

// Do something with the employee in the group here.

}

}

 

                                                          vii.      Practically, to get an item that can be directly bound to ASP.Net controls: 

var matches = from employee in employees

group employee by employee.TitleOfCourtesy into g

select new {Title = g.Key, Employees = g.Count()};

 Here Count() is an extension method.

Some of the other useful extensions:

var categories = from p in products

group p by p.Category into g

select new {Category = g.Key,

MaximumPrice = g.Max(p => p.UnitPrice),

MinimumPrice = g.Min(p => p.UnitPrice),

AveragePrice = g.Average(p => p.UnitPrice)};

                                                 

d.      LINQ to DataSet:

                                                               i.      DataSet.Select() has following drawbacks compared to LINQ:

1.       The expression inside Select() of DS is string and hence cannot be validated at compile time.

2.       It can sort and filter, but does not offer as many features as Linq (grouping etc.)

                                                             ii.      Usage Scenarios of LINQ to DataSet:

 

Un-typed DataSet:

To get a list of Employees whose LastName starts with "D". You are geting Data from the Employee table in DS

 

IEnumerable<DataRow> matches = from employee

in ds.Tables["Employees"].AsEnumerable()

where employee.Field<string>("LastName").StartsWith("D")

select employee;

                                                To bind this directly to a control:

gridEmployees.DataSource = matches.AsDataView(); // another extension method

NOTE: 

Field<String>(“Name”) – As DS does not expose strongly typed data (means data is accessed                 through datarows, columns etc.). This is one way for strongly typed access to DS.

AsEnumerable() :  As Data Table is not Enumerable, another extension method.

Typed DataSet:

var matches = from employee in ds.Employees

where employee.LastName.StartsWith("D")

select new { First = employee.FirstName, employee.LastName };

                                               It is much easier if you are dealing with Typed Datasets.

 

Next DLINQ...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Friday, March 28, 2008 10:20 AM | Feedback (5) |

Thursday, March 27, 2008

C# 3.5 Cool Features:

C# 3.5 provides a lot of good features and here are a few of them.

Implicitly Typed Local Variables:

The compiler derives the type from the initialized value.

// Implicitly typed local variables.

var myInt = 0;

var myBool = true;

var myString = "Time, marches on...";

 

These are greatly useful while using with LINQ.

Automatic properties:

No need to write the entire property syntax.

class Car

{

// Automatic property syntax.

public string PetName { get; set; }

}

 

·        But they cannot be used to define read-only or write only properties

// Read-only property? Error!

public int MyReadOnlyProp { get; }

 

·        Abstract Automatic Property can be defines as :

abstract class Car

{

// Abstract property in an abstract base class.

public abstract string PetName { get; set; }

}

 

·        Restricted Access to Automatic Properties:

Get can be public and set can be protected.

public string PetName { get; protected set; }

 

·        Default values are assigned automatically:

In the above case, PetName is assigned null when declared.
 

Extension Methods:

                                                               i.      This technique can be quite helpful when you need to inject new functionality into types for which you do not have an existing code base.

                                                             ii.      Extension methods are static methods and can be defined on any class for any other type.

The following code extends System.Object to have a new method.

static class MyExtensions

{

// This method allows any object to display the //assembly it is defined in.

public static void DisplayDefiningAssembly(this object obj)

{

Console.WriteLine("{0} lives here:\n\t->{1}\n", obj.GetType().Name,

Assembly.GetAssembly(obj.GetType()));

}

}

 

o   this on the first parameter mentions the extended method.

o   this can only be applied to first argument

o   Extension methods can take multiple arguments

 

                                                            iii.      Calling Extension Methods:

1.      On instance

int i = 0;

i.GetAssembly();

 

2.      Using static way:

MyExtensions.DisplayDefiningAssembly(myInt);

 

More on this later....
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Thursday, March 27, 2008 6:21 PM | Feedback (11) |

Monday, January 07, 2008

FOR XML Performance with SQL 2005

We had a requirement to generate some extract data in the form of XML.
So while designing the solution, I had 2 options.
1. Use FOR XML in the Query with SQL 2005
2. Use regular SQL Queries and usign a Custom DataSet, serialize the data to XML.

SQL 2005 has nice options to get the XML.
You can assign name spaces to nodes, can have nested XMLs, can have custom Root and Child Xml node names.
One example can be found here.
http://www.wrox.com/WileyCDA/Section/id-301088.html

But FOR XML queries are much slower when getting huge amounts of data.
You can find a comparison here.
http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1265579,00.html

So the bottom line is, FORXML is suitable only for small output.
Else do the logic in the business components.
And in most of the circumstances, the load on the database need to be kept low.
Hence second method was found the more suitable one.
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, January 07, 2008 12:10 PM | Feedback (3) |

WPF

WPF is the next generation Interface Design System for Windows Forms applications.
The arrival of WPF is going to change the WinForm application development a lot. The WPF has made many architectural changes to UI subsystem. Now there  is a better  element subsystem, notification mechanism for the changed events for the  UI elements etc.

What are the new features of WPF?
  1. Integration : With existing UI services like User32, WinForms, Direct3D etc.
  2. Simplified Development using XAML : Flexible UI composition using XAML
  3. Simplified Deployment: Deploy the UI to deploy as a WInForm or a browser enabled WinForm GUI (XBAP)
  4. Vector Graphics : implements vector based composition engine, allows graphics to scale based on screen resolution w/o loosing quality (eg: SVG : Scalable Vector Graphics)
  5. Document Portability : By supporting compression, custom meta data, digital signatures and XPS (Xml Paper Specifications)
Why XAML?
Provides us the facility to define UI declaratively using XML.

* Convenience of a declarative system

* The tool Expression Blend from MS is a designer tool that helps the designers to create rich UI and the same can be save

as an XAML file.

* The developer can take over the same fiel add the functionality in the code behind.

XBAP?
XABP is XML enabled browser application.
This is not a Web Application and is never a replacement to ASP.NET
Here is the comparison.

Stand Alone Windows

XBAP

Has full access to System resources

Xaml Browser Application:
This is not a web application.

The client is required to have the .NET Framework.3.0 installed on his computer, and the application will run within the security context of the browser.

 

Runs inside the browser, hosted by PresentationHost.exe, which loads the CLR

 

XBAP is for delivering the compiled WPF applications through Browser.

 

ASP.NET is to create a web application that is cross-browser compatible and to create "true" web applications.

 

Two navigation systems:

  1. Std Win form navigation
  2. New Hyperlink navigation

 

Structured Navigation

Runs under full truest security sandbox

Runs under partial truest security sandbox

 

Data Access:

Does not support direct DB access, have to use service oriented model.
(Web Service, WCF)

State Management:

*Application Object :

* Isolated Storage

State Management:

*Application Object :

* Isolated Storage

 




So how do you provide the similar rich UI to ASP.NET?
Silver Light is the answer for that.
http://silverlight.net/GetStarted/

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, January 07, 2008 6:54 AM | Feedback (3) |

Biztalk Magazine

I came across a good BizTalk online magazine.

http://biztalkhotrod.com/default.aspx

It has good content for Biztalkers..!
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, January 07, 2008 1:19 AM | Feedback (0) |

Powered by: