Part 2: LINQ Tips & Tricks [Things to get you started efficiently]

This blog entry is in continuation with my first post on Part 1: LINQ Tips & Tricks [Things to get you started efficiently]

Continuing to share some other important tips that you can take care of while developing with LINQ.

[9] Loading Options while working with tables in Relationships

You always need to struggle for performance as a LINQ Developer; perhaps because to understand better how internal mechanism works.

using (BEDataContext context = new BEDataContext())
{
    var customers = from cust in context.Customers
                    select cust;
    foreach (var customer in customer)
        Response.Write(customer.CustomerAddresses.Count().ToString());
}

Read More…

Part 1: LINQ Tips & Tricks [Things to get you started efficiently]

While my development with LINQ I got around some helps, links, small tips and tricks which makes life much easier, improves query formulation capabilities and speedup the program execute performance. Here I am sharing some of the tips I found as a LINQ Developer.

[1] Use the var Keyword When Confused

Use var keyword as return type especially when you are capturing sequence of anonymous classes. For example, joining of 2 tables and retrieving a sequence of records containing (some/few) fields of both the tables. I appreciate the developers who understand and know exactly what data type is contained in the sequence they are retrieving. But, anyhow you get stuck and don’t know the sequence IEnumerable<T> holds what data type T; then var is the good choice.

 

Read More…

How to create DotNetNuke(DNN) Scheduler

Did you ever need to write disconnected process which should be run at a defined interval time? Commonly, when we are in such need – we use to write window service which is based on some timer mechanism where we set some interval for the timer and in its elapsed method we execute the process we want to run at defined interval.

When you work with DotNetNuke and you come across with such functionality that need tobe implemented – you can consider creating “DotNetNuke Scheduler”. While creating a DNN Scheduler – you are actually creating a simple class library which would be built and hosted in the DNN Schedule environment to be executed at the defined interval time.

The possible scenario in which one need to look at such schedule functionality is:
[1] You may need to send some set of fixed newletter everyday at defiend time to your customers.
[2] You may need to read some of third party product feed to read regular update and modify your product database.
[3] You may need to send some system generated reports to your third party vendor at some regular intervals.

Read More…

How would you create a perfect DotNetNuke (DNN) Environment/Installation

Today, I am going to describe complete process of creating a perfect DotNetNuke Environment or say how would you install DNN Site (whether install or source version). I am going to use most latest and stable 05.04.00 install version of DotNetNuke. To download the source/install version you need to have login/account at official DotNetNuke site. Once you login; you would go to Download page where you can select “Community” Edition to download. There are 2 variations in DotNetNuke that you would find there. One is Community Edition and other is “Professional” edition. You can install DotNetNuke via downloading “Microsoft Web Platform Installer” that is available on the same page. This installer additionally provides you other valuable resources to install as well. For more information on Web Platform you would get here – http://www.microsoft.com/web/default.aspx, Otherwise, you may click on the “Older version” link which would redirect you to the version track page at “Codeplex” site. You would find the total “Release Track/History” at the right hand side. I have selected most stable install version to download.

Read More..

DotNetNuke – Where do you write your application CSS?

after Long time…. back in the community finally… :)

I was working in DNN application since I used to add css classes as and when I need to add which are related to specific my custom dnn modules. Initially, I used to add those classes in MinimulExtropy skin css file. But, as time goes.. it grows in size and there are situations when skin tend to change everytime (because some skin related issues or client didnt like it). Sp, everytime when any skin got changed I need to manually “copy” and “paste” those application (related to custom desktop modules) css classes in to the targetted skin folder’s css files. Because, somehow AFAIK dnn doesn’t support App_Theme folder or .skin files (because of its skin architecture).

Read More…

Tried first video on youtube

I give a try with windows live movie maker > http://www.youtube.com/watch?v=QEjTZtQ_oqM

hope you like it (also wish to make you think!)

pooh… is that really u?

Just look at what I found from my MCA II Sem CONM book…  :)

File download problem: filename with spaces truncated in FF and replaced by underscore in IE

This is a mere note to remember for future rather than a blog entry. While I am working on code to download file from server. I write below code:

        {
            int ChunkSize = 10000;
            string sFileFullPath = Server.MapPath("New Text Document.txt");
            System.IO.FileInfo toDownload = new System.IO.FileInfo(sFileFullPath);
            if (System.IO.File.Exists(sFileFullPath))
            {
                Response.Clear();
                using (FileStream iStream = System.IO.File.OpenRead(sFileFullPath))
                {
                    long dataLengthToRead = iStream.Length;
                    Byte[] buffer = new Byte[dataLengthToRead];
                    Response.ContentType = "application/octet-stream";
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
                    while (ChunkSize > 0 && Response.IsClientConnected)
                    {
                        if (ChunkSize > dataLengthToRead)
                        {
                            ChunkSize = int.Parse(dataLengthToRead.ToString());
                        }
                        int lengthRead = iStream.Read(buffer, 0, ChunkSize);
                        Response.OutputStream.Write(buffer, 0, lengthRead);
                        Response.Flush();
                        dataLengthToRead = dataLengthToRead - lengthRead;
                    }
                }
                Response.Close();
                Response.End();
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(GetType(), "ShowMessage", "<script language='javascript'>alert('No Files Available');</script>");
            }
        }

When I ran the application I found that the file which I need to download was containing spaces in its name like “New Text Document.txt”.

The problem is:

Read More

OnKeyPress event – event.keyCode and event.which (validating for numarics)

I am trying to validate textbox for numeric entry, while I added this code to accomplish in page_load event:

textbox.Attributes.Add(“onkeypress”, “return (window.event.keyCode == 45 || window.event.keyCode == 13 || window.event.keyCode == 8 || window.event.keyCode == 9 || window.event.keyCode == 189 || window.event.keyCode == 109 || (window.event.keyCode >= 48 && window.event.keyCode <= 58) )”);

It worked fine in IE7 and IE8, but it didnt work for FF though. A bit googling gave me conclusion that….

Read More

DotNetNuke – Invalid URI: The hostname could not be parsed error

Generally, I would like to blog post any errors that I face duing development. So that it would be helpful to me for my future reference in case I face it again as well as for the sake of any blog readers who may face same error.

Talking about the error “Invalid URI: The hostname could not be parsed error”: This the same and common error I faced previously some times back and which I also stated in my blog entry DotNetNuke – Invalid URI: The hostname could not be parsed

This time I was about to run a DNN application which is configured from my local server to live application server when I faced the same error. I tried the same work-a-round which I stated in my previous blog entry. But, this time that didn’t work even after investing some hrs investigation.

Read More

Follow

Get every new post delivered to your Inbox.