Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CHCorporate_Test.Models;
using Mindscape.LightSpeed;
namespace Demo
{
class Program
{
private static LightSpeedContext _context;
static void Main(string[] args)
{
// you can change context values programmatically,
_context = new LightSpeedContext<RFPUnitOfWork>("default");
using (var uow = _context.CreateUnitOfWork())
{
Console.WriteLine("RFPs: " + uow.Rfps.Count() );
//**Error 1** // The ConnectionString property has not been initialized.
//**Error 2** // ExecuteScalar requires an open and available Connection. The connection's current state is closed.
Console.ReadLine();
}
}
}
}
App.config
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<configSections>
<section name="lightSpeedContexts"
type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection,
Mindscape.LightSpeed" />
</configSections>
<connectionStrings>
<add name="chdev" connectionString="server=chdev; database=CHCorporate; uid=sa; pwd=password;" />
</connectionStrings>
<lightSpeedContexts>
<add name="default"
connectionStringNme="chdev"
dataProvider="SqlServer2005" />
</lightSpeedContexts>
The Lightspeed Model code:
RFP.cs
using System;
using Mindscape.LightSpeed;
using Mindscape.LightSpeed.Validation;
using Mindscape.LightSpeed.Linq;
namespace CHCorporate_Test.Models
{
[Serializable]
[System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
[System.ComponentModel.DataObject]
public partial class Rfp : Entity
{
#region Fields
[ValidateLength(0, 255)]
private string _firmName;
[ValidateLength(0, 255)]
private string _name;
[ValidateLength(0, 255)]
private string _title;
[ValidateLength(0, 255)]
private string _phone;
[ValidateEmailAddress]
[ValidateLength(0, 255)]
private string _email;
[ValidateLength(0, 255)]
private string _address;
[ValidateLength(0, 255)]
private string _city;
[ValidateLength(0, 255)]
private string _state;
[ValidateLength(0, 255)]
private string _zipcode;
[ValidateLength(0, 255)]
private string _clientCompanyName;
[ValidateLength(0, 255)]
private string _clientName;
[ValidateLength(0, 255)]
private string _clientTitle;
[ValidateLength(0, 255)]
private string _clientPhone;
[ValidateLength(0, 255)]
private string _clientEmail;
[ValidateLength(0, 255)]
private string _clientAddress;
[ValidateLength(0, 255)]
private string _clientCity;
[ValidateLength(0, 255)]
private string _clientState;
[ValidateLength(0, 255)]
private string _clientZipcode;
[ValidateLength(0, 255)]
private string _clientUrl;
private System.Nullable<int> _clientEligibleEmployees;
private System.Nullable<int> _clientEnrolledEmployees;
private System.Nullable<int> _clientEnrolledDependents;
private System.Nullable<double> _clientCostPerDependent;
[ValidateLength(0, 255)]
private string _brokerCompensation;
private System.Nullable<System.DateTime> _date;
#endregion
#region Field attribute and view names
/// <summary>Identifies the FirmName entity attribute.</summary>
public const string FirmNameField = "FirmName";
/// <summary>Identifies the Name entity attribute.</summary>
public const string NameField = "Name";
/// <summary>Identifies the Title entity attribute.</summary>
public const string TitleField = "Title";
/// <summary>Identifies the Phone entity attribute.</summary>
public const string PhoneField = "Phone";
/// <summary>Identifies the Email entity attribute.</summary>
public const string EmailField = "Email";
/// <summary>Identifies the Address entity attribute.</summary>
public const string AddressField = "Address";
/// <summary>Identifies the City entity attribute.</summary>
public const string CityField = "City";
/// <summary>Identifies the State entity attribute.</summary>
public const string StateField = "State";
/// <summary>Identifies the Zipcode entity attribute.</summary>
public const string ZipcodeField = "Zipcode";
/// <summary>Identifies the ClientCompanyName entity attribute.</summary>
public const string ClientCompanyNameField = "ClientCompanyName";
/// <summary>Identifies the ClientName entity attribute.</summary>
public const string ClientNameField = "ClientName";
/// <summary>Identifies the ClientTitle entity attribute.</summary>
public const string ClientTitleField = "ClientTitle";
/// <summary>Identifies the ClientPhone entity attribute.</summary>
public const string ClientPhoneField = "ClientPhone";
/// <summary>Identifies the ClientEmail entity attribute.</summary>
public const string ClientEmailField = "ClientEmail";
/// <summary>Identifies the ClientAddress entity attribute.</summary>
public const string ClientAddressField = "ClientAddress";
/// <summary>Identifies the ClientCity entity attribute.</summary>
public const string ClientCityField = "ClientCity";
/// <summary>Identifies the ClientState entity attribute.</summary>
public const string ClientStateField = "ClientState";
/// <summary>Identifies the ClientZipcode entity attribute.</summary>
public const string ClientZipcodeField = "ClientZipcode";
/// <summary>Identifies the ClientUrl entity attribute.</summary>
public const string ClientUrlField = "ClientUrl";
/// <summary>Identifies the ClientEligibleEmployees entity attribute.</summary>
public const string ClientEligibleEmployeesField = "ClientEligibleEmployees";
/// <summary>Identifies the ClientEnrolledEmployees entity attribute.</summary>
public const string ClientEnrolledEmployeesField = "ClientEnrolledEmployees";
/// <summary>Identifies the ClientEnrolledDependents entity attribute.</summary>
public const string ClientEnrolledDependentsField = "ClientEnrolledDependents";
/// <summary>Identifies the ClientCostPerDependent entity attribute.</summary>
public const string ClientCostPerDependentField = "ClientCostPerDependent";
/// <summary>Identifies the BrokerCompensation entity attribute.</summary>
public const string BrokerCompensationField = "BrokerCompensation";
/// <summary>Identifies the Date entity attribute.</summary>
public const string DateField = "Date";
#endregion
#region Properties
[System.Diagnostics.DebuggerNonUserCode]
public string FirmName
{
get { return Get(ref _firmName, "FirmName"); }
set { Set(ref _firmName, value, "FirmName"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string Name
{
get { return Get(ref _name, "Name"); }
set { Set(ref _name, value, "Name"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string Title
{
get { return Get(ref _title, "Title"); }
set { Set(ref _title, value, "Title"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string Phone
{
get { return Get(ref _phone, "Phone"); }
set { Set(ref _phone, value, "Phone"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string Email
{
get { return Get(ref _email, "Email"); }
set { Set(ref _email, value, "Email"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string Address
{
get { return Get(ref _address, "Address"); }
set { Set(ref _address, value, "Address"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string City
{
get { return Get(ref _city, "City"); }
set { Set(ref _city, value, "City"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string State
{
get { return Get(ref _state, "State"); }
set { Set(ref _state, value, "State"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string Zipcode
{
get { return Get(ref _zipcode, "Zipcode"); }
set { Set(ref _zipcode, value, "Zipcode"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientCompanyName
{
get { return Get(ref _clientCompanyName, "ClientCompanyName"); }
set { Set(ref _clientCompanyName, value, "ClientCompanyName"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientName
{
get { return Get(ref _clientName, "ClientName"); }
set { Set(ref _clientName, value, "ClientName"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientTitle
{
get { return Get(ref _clientTitle, "ClientTitle"); }
set { Set(ref _clientTitle, value, "ClientTitle"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientPhone
{
get { return Get(ref _clientPhone, "ClientPhone"); }
set { Set(ref _clientPhone, value, "ClientPhone"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientEmail
{
get { return Get(ref _clientEmail, "ClientEmail"); }
set { Set(ref _clientEmail, value, "ClientEmail"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientAddress
{
get { return Get(ref _clientAddress, "ClientAddress"); }
set { Set(ref _clientAddress, value, "ClientAddress"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientCity
{
get { return Get(ref _clientCity, "ClientCity"); }
set { Set(ref _clientCity, value, "ClientCity"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientState
{
get { return Get(ref _clientState, "ClientState"); }
set { Set(ref _clientState, value, "ClientState"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientZipcode
{
get { return Get(ref _clientZipcode, "ClientZipcode"); }
set { Set(ref _clientZipcode, value, "ClientZipcode"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string ClientUrl
{
get { return Get(ref _clientUrl, "ClientUrl"); }
set { Set(ref _clientUrl, value, "ClientUrl"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public System.Nullable<int> ClientEligibleEmployees
{
get { return Get(ref _clientEligibleEmployees, "ClientEligibleEmployees"); }
set { Set(ref _clientEligibleEmployees, value, "ClientEligibleEmployees"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public System.Nullable<int> ClientEnrolledEmployees
{
get { return Get(ref _clientEnrolledEmployees, "ClientEnrolledEmployees"); }
set { Set(ref _clientEnrolledEmployees, value, "ClientEnrolledEmployees"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public System.Nullable<int> ClientEnrolledDependents
{
get { return Get(ref _clientEnrolledDependents, "ClientEnrolledDependents"); }
set { Set(ref _clientEnrolledDependents, value, "ClientEnrolledDependents"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public System.Nullable<double> ClientCostPerDependent
{
get { return Get(ref _clientCostPerDependent, "ClientCostPerDependent"); }
set { Set(ref _clientCostPerDependent, value, "ClientCostPerDependent"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public string BrokerCompensation
{
get { return Get(ref _brokerCompensation, "BrokerCompensation"); }
set { Set(ref _brokerCompensation, value, "BrokerCompensation"); }
}
[System.Diagnostics.DebuggerNonUserCode]
public System.Nullable<System.DateTime> Date
{
get { return Get(ref _date, "Date"); }
set { Set(ref _date, value, "Date"); }
}
#endregion
}
///
/// Provides a strong-typed unit of work for working with the RFP model.
///
[System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
public partial class RFPUnitOfWork : Mindscape.LightSpeed.UnitOfWork
{
public System.Linq.IQueryable Rfps
{
get { return this.Query(); }
}
}
}