الأربعاء، 30 نوفمبر 2011

Entity Framework Batch Update and Future Queries

Entity Framework Extended Library

A library the extends the functionality of Entity Framework.

Features

  • Batch Update and Delete
  • Future Queries
  • Audit Log
Project Package and Source

NuGet Package

PM> Install-Package EntityFramework.Extended

Batch Update and Delete

A current limitations of the Entity Framework is that in order to update or delete an entity you have to first retrieve it into memory. Now in most scenarios this is just fine. There are however some senerios where performance would suffer. Also, for single deletes, the object must be retrieved before it can be deleted requiring two calls to the database. Batch update and delete eliminates the need to retrieve and load an entity before modifying it.

Deleting

//delete all users where FirstName matches context.Users.Delete(u => u.FirstName == "firstname"); 

Update

//update all tasks with status of 1 to status of 2 context.Tasks.Update(     t => t.StatusId == 1,      t => new Task {StatusId = 2});  //example of using an IQueryable as the filter for the update var users = context.Users    .Where(u => u.FirstName == "firstname");  context.Users.Update(     users,      u => new User {FirstName = "newfirstname"}); 
Future Queries

Build up a list of queries for the data that you need and the first time any of the results are accessed, all the data will retrieved in one round trip to the database server. Reducing the number of trips to the database is a great. Using this feature is as simple as appending .Future() to the end of your queries. To use the Future Queries, make sure to import the EntityFramework.Extensions namespace.

Future queries are created with the following extension methods...

  • Future()
  • FutureFirstOrDefault()
  • FutureCount()

Sample

// build up queries var q1 = db.Users     .Where(t => t.EmailAddress == "one@test.com")     .Future();  var q2 = db.Tasks     .Where(t => t.Summary == "Test")     .Future();  // this triggers the loading of all the future queries var users = q1.ToList(); 

In the example above, there are 2 queries built up, as soon as one of the queries is enumerated, it triggers the batch load of both queries.

// base query var q = db.Tasks.Where(t => t.Priority == 2); // get total count var q1 = q.FutureCount(); // get page var q2 = q.Skip(pageIndex).Take(pageSize).Future();  // triggers execute as a batch int total = q1.Value; var tasks = q2.ToList(); 

In this example, we have a common senerio where you want to page a list of tasks. In order for the GUI to setup the paging control, you need a total count. With Future, we can batch together the queries to get all the data in one database call.

Future queries work by creating the appropriate IFutureQuery object that keeps the IQuerable. The IFutureQuery object is then stored in IFutureContext.FutureQueries list. Then, when one of the IFutureQuery objects is enumerated, it calls back to IFutureContext.ExecuteFutureQueries() via the LoadAction delegate. ExecuteFutureQueries builds a batch query from all the stored IFutureQuery objects. Finally, all the IFutureQuery objects are updated with the results from the query.

Audit Log

The Audit Log feature will capture the changes to entities anytime they are submitted to the database. The Audit Log captures only the entities that are changed and only the properties on those entities that were changed. The before and after values are recorded. AuditLogger.LastAudit is where this information is held and there is a ToXml() method that makes it easy to turn the AuditLog into xml for easy storage.

The AuditLog can be customized via attributes on the entities or via a Fluent Configuration API.

Fluent Configuration

// config audit when your application is starting up... var auditConfiguration = AuditConfiguration.Default;  auditConfiguration.IncludeRelationships = true; auditConfiguration.LoadRelationships = true; auditConfiguration.DefaultAuditable = true;  // customize the audit for Task entity auditConfiguration.IsAuditable<Task>()     .NotAudited(t => t.TaskExtended)     .FormatWith(t => t.Status, v => FormatStatus(v));  // set the display member when status is a foreign key auditConfiguration.IsAuditable<Status>()     .DisplayMember(t => t.Name); 

Create an Audit Log

var db = new TrackerContext(); var audit = db.BeginAudit();  // make some updates ...  db.SaveChanges(); var log = audit.LastLog;

Source: http://weblogs.asp.net/pwelter34/archive/2011/11/29/entity-framework-batch-update-and-future-queries.aspx

how to build your own computer how to computer how to build a computer how to text from computer how to back up computer how to learn computer how to connect computer to tv how to how to use a computer how to hack a computer

Using SqlParameter Class

Represents a parameter to a SqlCommand and optionally its mapping to DataSet columns. This class cannot be inherited.

You should use parameters to filter queries in a secure manner. But I recommend to use parameters when you try to pass the datetime value in your query.

The process of using parameter contains two steps:
  • create SqlParameter object and insert there value with applicable properties
  • define the parameter in the SqlCommand command string, and assign the SqlParameter object to the SqlCommand object. When the SqlCommand executes, parameters will be replaced with values specified by the SqlParameter object.

Sample Code

Imports Namespace: System.Data.SqlClient

' Insert string
Dim sql As String = " INSERT INTO tblZipCode([ZIPCODE], [STATE], [CITY], [TestDate]) VALUES(@ZIPCODE, @STATE, @CITY), @TestDate"

' Create sql parameter
Dim param(3) As SqlParameter

param(0) = New SqlParameter("@ZIPCODE", SqlDbType.VarChar)
param(0).Value = "60000"

param(1) = New SqlParameter("@STATE", SqlDbType.VarChar)
param(1).Value = "Statename"

param(2) = New SqlParameter("@CITY", SqlDbType.VarChar)
param(2).Value = "Cityname"

' Recommend to use sql param when you try to send datetime value
param(3) = New SqlParameter("@TestDate", SqlDbType.DateTime)
param(3).Value = DateTime.Now

' Create Connection string
Dim sConnection As New SqlConnection("server=(local);uid=sa;pwd=pass;database=db")
sConnection.Open()

' Create Sql Command
Dim command As SqlCommand = sConnection.CreateCommand()
command.CommandText = sql

' Add Parameter to command
command.Parameters.AddRange(param)

' Execute command
Dim nResult As Integer = command.ExecuteNonQuery()

If nResult > 0 Then
Console.WriteLine("Insert completed")
End If

sConnection.Close()
command.Dispose()

Source: http://vbnetsample.blogspot.com/2007/10/using-sqlparameter-class.html

asp.net tutorials asp.net videos asp.net datagrid how to learn asp.net how to learn asp.net quickly how to deploy asp.net application asp.net ajax asp.net repeater how to send email from asp.net how to program

الاثنين، 28 نوفمبر 2011

What Are the Standard Features Any Email Marketing System Should Have? It Depends

If you ask which standard features to look for in an email marketing system, you’re asking the wrong question. The correct question is what do you need. Here’s why…

"It depends."
Recently at a marketing conference, one of the speakers stated that consultants are notorious for starting their answers with phrases like, "It depends."

Clients might think that’s a runaround. It’s not. Quite often, the answer to a client’s question isn’t, “If you do X, you will get Y”. Quite often it’s, “It depends.”

That’s also the way to start off any answer to any question about the features to look for when considering an email marketing system. It depends on what your needs are.

If choosing an ESP or email marketing system meant looking for standard features only, we likely wouldn't have over 100 ESPs to choose from. If there were standard features that narrowed down your choice and made comparisons easy, many of us would likely be out of business.

In reality, email marketing systems come with a wide range of capabilities in order to fulfill a wide range of business requirements. As a result, comparing email marketing systems or ESPs is like comparing apples to oranges.

If you can't simply start with a checklist, then where do you start? You start with your requirements. That is your checklist. The question shouldn’t be, "What features should we look for?" Rather, "What features do we need?"

Two factors you must consider
There are two factors you must consider no matter the ESP or email marketing system. One is the deliverability rate and the other is uptime. No matter the provider or system you choose, the deliverability rate and the uptime have to be as high as possible.

Uptime is easy to determine: Ask.

However, with deliverability "it depends" because it will vary for everyone. If one ESP gets a 97.3% deliverability rate for one customer and list, it doesn’t follow that they’ll achieve that same deliverability rate for another company with a different list. To make sure you choose an ESP or system with the highest deliverability rate for you, try and take your choices for a test drive, using the system to mail to your own list to test deliverability.

Unfortunately there isn't any one checklist that’s going to help you find the features you must have, but finding an ESP with an uptime of 99.5% or higher and high deliverability among its IP addresses is key to finding an ESP that is going to serve your best long-term.


- Marco Marini
CEO
ClickMail Marketing
 

Source: http://blog.emailexperience.org/blog/clickmail-marketing-at-eec/what-are-the-standard-features-any-email-marketing-system-should-have-v1

array vb.net about vb.net how to vb.net how to convert vb6 to vb.net how to learn vb.net free programming courses free lance programming free online programming courses free game programming software free cnc programming software

Fresh Content from the DMA UK

The DMA UK’s Email Marketing Council maintains a blog featuring Council members writing about a wide range of topics relating to email marketing.

Here are this month’s highlights:
  • An example of how to use email and social to drive both list growth and sales. 
  • A recent Return Path study confirms that a marketer’s sender reputation is the key to achieving high inbox placement rates and avoiding the spam folder.
  • ISPs have been announcing various types of inbox filtering – here’s a look at how they might impact marketers.
  • Frameworks are used in many different industries to structure thinking, people and processes effectively – here’s how they can be applied to email marketing. 
  • Email marketing produces a huge volume and range of metrics; using a SMART (Specific, Measurable, Agreed,  Realistic, Time Bound) approach will help marketers measure their specific ROI.

Source: http://blog.emailexperience.org/blog/contributors-to-the-eec-blog/fresh-content-from-the-dma-uk

how to text from computer how to back up computer how to learn computer how to connect computer to tv how to how to use a computer how to hack a computer how to convert vb6 to .net how to vb6 how to convert vb6 to vb.net

الأحد، 27 نوفمبر 2011

Creating parent-child relationships between tables in ASP.NET ...

Read More......(read more)

Source: http://www.codeproject.com/KB/aspnet/Parent-Child-DataTables.aspx

c programming software free download free download c programming software free computer programming software c programming free download free download c programming c programming download free free programming ebooks how to learn c# how to c# string in c#

The Springboard Series Visits Lima, Peru

Our second stop in South America was Lima, Peru. Day one we discussed the Proof Of Concept Jumpstart Kit with local companies currently testing their application compatibility and deployment strategies. Day two was a full day of presentations on embracing consumerization, leveraging free deployment tools like MDT, MAP and ACT and ended the day showing off the great features and functionality of Windows Intune. The day concluded with the Microsoft Peru office turning the event room into a gigantic viewing party for the big soccer match between Peru and Ecuador. We had a great time but we need to get to Argentina for our next event. Check out the video and see you in Buenos Aires!

Get Microsoft Silverlight

Source: http://windowsteamblog.com/windows/b/springboard/archive/2011/11/18/the-springboard-series-visits-lima-peru.aspx

asp.net videos asp.net datagrid how to learn asp.net how to learn asp.net quickly how to deploy asp.net application asp.net ajax asp.net repeater how to send email from asp.net how to program how to programming