示例#1
0
        protected override string GetQuery(BaseProcessingModel model)
        {
            var contact = (ContactProcessingModel)model;

            return(string.Format
                       (@"
                do $$ begin
                if (select 1 from ""Contact"" where ""Id""='{2}') then
                    UPDATE ""public"".""Contact"" SET ""Name"" = '{0}', ""Phone"" = '{1}', ""BrandId"" = '{3}' WHERE ""Id"" = '{2}';
                ELSE
                    INSERT INTO ""public"".""Contact"" (""Name"", ""Phone"", ""Id"", ""BrandId"") VALUES ('{0}', '{1}', '{2}', '{3}');
                END IF;
                END $$
                ",
                       (contact.Name ?? "").Replace("'", "''"), (contact.Phone ?? "").Replace("'", "''"), contact.Id.ToString(), _defaultBrandId));
        }
示例#2
0
 protected abstract string GetQuery(BaseProcessingModel model);
示例#3
0
        protected override string GetQuery(BaseProcessingModel model)
        {
            var contact = (ContactProcessingModel)model;

            return(string.Format
                       (@"
                do $$ begin
                if (select 1 from ""Contact"" where ""Id""='{2}') then
                    UPDATE 
						""public"".""Contact"" 
					SET 
						""Name_FirstName"" = '{0}', 
						""Phone"" = '{1}', 
						""BrandId"" = '{3}', 
						""Name_Surname"" = '{4}', 
						""Name_MiddleName"" = '{5}',
						""Email"" = '{6}',
						""Gender"" = {7},
						""Address_Country"" = '{8}',
						""Address_City"" = '{9}',
						""Address_Address"" = '{10}',
						""Birthday"" = {11},
						""RegistrationPlaceId"" = (SELECT ""Id"" FROM ""public"".""Shop"" WHERE ""Code"" = '{12}'),
						""RegistrationDate"" = {13},
						""PhoneConfirmed"" = {14},
						""Code"" = '{15}'
					WHERE ""Id"" = '{2}';
                ELSE
                    INSERT INTO ""public"".""Contact"" (
						""Name_FirstName"", 
						""Phone"", 
						""Id"", 
						""BrandId"", 
						""Name_Surname"", 
						""Name_MiddleName"", 
						""Email"",
						""Gender"",
						""Address_Country"",
						""Address_City"",
						""Address_Address"",
						""Birthday"",
						""RegistrationPlaceId"",
						""RegistrationDate"",
						""PhoneConfirmed"",
						""Code""
						) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', {7}, '{8}', '{9}', '{10}', {11}, (SELECT ""Id"" FROM ""public"".""Shop"" WHERE ""Code"" = '{12}'), {13}, {14}, '{15}');
                END IF;
                END $$
                ",
                       (contact.FirstName ?? String.Empty).Replace("'", "''"),
                       (contact.Phone ?? String.Empty).Replace("'", "''"),
                       contact.Id.ToString(),
                       _defaultBrandId,
                       (contact.Surname ?? String.Empty).Replace("'", "''"),
                       (contact.MiddleName ?? String.Empty).Replace("'", "''"),
                       (contact.Email ?? String.Empty).Replace("'", "''"),
                       contact.IsGenderNull ? "null" : (contact.Gender == "1" ? "0" : "1"),
                       (contact.Country ?? String.Empty).Replace("'", "''"),
                       (contact.City ?? String.Empty).Replace("'", "''"),
                       (contact.Address ?? String.Empty).Replace("'", "''"),
                       String.IsNullOrEmpty(contact.Birthday) ? "null" : String.Format("'{0}'", contact.Birthday.Replace("'", "''")),
                       (contact.ShopCode ?? String.Empty).Replace("'", "''"),
                       String.IsNullOrEmpty(contact.RegistrationDate) ? "null" : String.Format("'{0}'", contact.RegistrationDate.Replace("'", "''")),
                       "false",
                       contact.Code
                       ));
        }