On Tue, Jun 17, 2008 at 7:50 AM, MB Software Solutions General Account
>
>
>
> Absolutely so true. If anyone out there starts a new project and wants
> to use MySQL as the backend, just let me know and I'll ship them a copy
> of the framework I used in one of my latest projects.
>
> Unless you're addicted to SET RELATION or SET SKIP or SEEK(...) in your
> direct tables or must have the DataEnvironment with VFP tables, you'll
> be able to use this (I hope) with great success....at which point,
> you'll probably consider staying with MySQL (or a non-DBF backend).
>
---------------------------------------------------
This is a linq pass at getting data from your backend and then posting to an
object that is returned. The notion of USER is a "rights to their data"
that allows our customers access to their coworkers.
public Address GetAddress(Guid addressId)
{
//Verfiy Validity of arguments
if (addressId == Guid.Empty)
{
InvalidArgumentFaultDetail.ThrowException("addressId",
"addressId cannot be null.");
}
//Get the current user
UserIdentity user =
((UserIdentity)ServiceSecurityContext.Current.PrimaryIdentity);
//Run the query
using (AddressingSystemEntities addressSystem = new
AddressingSystemEntities())
{
// get distributionlist id
var distributionListId = (from distributionList in
addressSystem.DistributionListAddress
where distributionList.AddressId
== addressId
select
distributionList.DistributionListId).FirstOrDefault();
var addressEntry = (from address in addressSystem.Address
join addressbook in
addressSystem.AddressBook
on address.AddressBook.Id equals
addressbook.Id
//join distributionList in
addressSystem.DistributionListAddress
//on address.Id equals
distributionList.AddressId into da
//from subDistributionList in
da.DefaultIfEmpty()
where (address.Id == addressId) &&
(addressbook.OwnerUserId == user.Id)
select new Address
{
FirstName = address.FirstName,
LastName = address.LastName,
Name = address.Name,
AddressBookId =
address.AddressBook.Id,
ApartmentOrSuite =
address.ApartmentOrSuite,
CareOf = address.CareOf,
City = address.City,
CompanyName = address.CompanyName,
CountryCode = address.CountryCode,
CustomData = address.CustomData,
Email = address.Email,
Id = addressId,
IsResidential =
address.IsResidential,
LastShippedTo =
address.LastShippedTo,
PostalCode = address.PostalCode,
StateOrProvince =
address.StateOrProvince,
Street = address.Street,
TelephoneNumber =
address.TelephoneNumber,
TelephoneNumber2 =
address.TelephoneNumber2,
Validated = address.Validated,
Version = address.Version,
DistributionListId =
distributionListId, //(subDistributionList == null?Guid.Empty :
subDistributionList.DistributionListId),
Prefix = address.Prefix
}).FirstOrDefault();
if (addressEntry == null)
{
NullObjectReturnedFaultDetail.ThrowException("addressEntry returned null.");
}
return addressEntry;
}
Over then next 6 months I will be writing this type of query for hundreds of
tables, joined tables and views.
The updates are very simple in that I pull back the row for the guid, make
the change and then tell the db to .SaveChanges So I could have multiple
rows in one table that will get an update as well as 5 other single rows
that are all updated on the same command.
--
Stephen Russell
Sr. Production Systems Programmer
Mimeo.com
Memphis TN
901.246-0159
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.